
<!DOCTYPE html
  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
   
      <title>Chapter&nbsp;14.&nbsp;Blocks and Statements</title>
      <link rel="stylesheet" type="text/css" href="../../../javaspec.css">
      <meta name="generator" content="DocBook XSL-NS Stylesheets V1.76.1">
      <link rel="home" href="index.html" title="The Java&reg; Language Specification">
      <link rel="up" href="index.html" title="The Java&reg; Language Specification">
      <link rel="prev" href="jls-13.html" title="Chapter&nbsp;13.&nbsp;Binary Compatibility">
      <link rel="next" href="jls-15.html" title="Chapter&nbsp;15.&nbsp;Expressions">
      <link rel="copyright" href="jls-0-front.html" title="Legal Notice">
   </head>
   <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
      <div xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:rx="http://www.renderx.com/XSL/Extensions" id="logo"><img src="http://www.oracleimg.com/us/assets/oralogo-small.gif" alt="Oracle Logo"><br><p><a target="_blank" href="http://www.oracle.com/us/technologies/java/">Oracle
                   Technology Network</a> &gt; <a target="_blank" href="http://docs.oracle.com/javase/">Java SE</a>
                &gt; <a href="index.html">Java Language Specification</a></p>
      </div>
      <div class="navheader">
         <table width="100%" summary="Navigation header">
            <tr>
               <th colspan="3" align="center">Chapter&nbsp;14.&nbsp;Blocks and Statements</th>
            </tr>
            <tr>
               <td width="20%" align="left"><a accesskey="p" href="jls-13.html">Prev</a>&nbsp;
               </td>
               <th width="60%" align="center">&nbsp;</th>
               <td width="20%" align="right">&nbsp;<a accesskey="n" href="jls-15.html">Next</a></td>
            </tr>
         </table>
         <hr>
      </div>
      <div lang="en" class="chapter" title="Chapter&nbsp;14.&nbsp;Blocks and Statements">
         <div class="titlepage">
            <div>
               <div>
                  <h2 class="title"><a name="jls-14"></a>Chapter&nbsp;14.&nbsp;Blocks and Statements
                  </h2>
               </div>
            </div>
         </div>
         <div class="toc">
            <p><b>Table of Contents</b></p>
            <dl>
               <dt><span class="section"><a href="jls-14.html#jls-14.1">14.1. Normal and Abrupt Completion of Statements</a></span></dt>
               <dt><span class="section"><a href="jls-14.html#jls-14.2">14.2. Blocks</a></span></dt>
               <dt><span class="section"><a href="jls-14.html#jls-14.3">14.3. Local Class Declarations</a></span></dt>
               <dt><span class="section"><a href="jls-14.html#jls-14.4">14.4. Local Variable Declaration Statements</a></span></dt>
               <dd>
                  <dl>
                     <dt><span class="section"><a href="jls-14.html#jls-14.4.1">14.4.1. Local Variable Declarators and Types</a></span></dt>
                     <dt><span class="section"><a href="jls-14.html#jls-14.4.2">14.4.2. Execution of Local Variable Declarations</a></span></dt>
                  </dl>
               </dd>
               <dt><span class="section"><a href="jls-14.html#jls-14.5">14.5. Statements</a></span></dt>
               <dt><span class="section"><a href="jls-14.html#jls-14.6">14.6. The Empty Statement</a></span></dt>
               <dt><span class="section"><a href="jls-14.html#jls-14.7">14.7. Labeled Statements</a></span></dt>
               <dt><span class="section"><a href="jls-14.html#jls-14.8">14.8. Expression Statements</a></span></dt>
               <dt><span class="section"><a href="jls-14.html#jls-14.9">14.9. The <code class="literal">if</code> Statement</a></span></dt>
               <dd>
                  <dl>
                     <dt><span class="section"><a href="jls-14.html#jls-14.9.1">14.9.1. The <code class="literal">if</code>-<code class="literal">then</code> Statement</a></span></dt>
                     <dt><span class="section"><a href="jls-14.html#jls-14.9.2">14.9.2. The <code class="literal">if</code>-<code class="literal">then</code>-<code class="literal">else</code> Statement</a></span></dt>
                  </dl>
               </dd>
               <dt><span class="section"><a href="jls-14.html#jls-14.10">14.10. The <code class="literal">assert</code> Statement</a></span></dt>
               <dt><span class="section"><a href="jls-14.html#jls-14.11">14.11. The <code class="literal">switch</code> Statement</a></span></dt>
               <dt><span class="section"><a href="jls-14.html#jls-14.12">14.12. The <code class="literal">while</code> Statement</a></span></dt>
               <dd>
                  <dl>
                     <dt><span class="section"><a href="jls-14.html#jls-14.12.1">14.12.1. Abrupt Completion of <code class="literal">while</code> Statement</a></span></dt>
                  </dl>
               </dd>
               <dt><span class="section"><a href="jls-14.html#jls-14.13">14.13. The <code class="literal">do</code> Statement</a></span></dt>
               <dd>
                  <dl>
                     <dt><span class="section"><a href="jls-14.html#jls-14.13.1">14.13.1. Abrupt Completion of <code class="literal">do</code> Statement</a></span></dt>
                  </dl>
               </dd>
               <dt><span class="section"><a href="jls-14.html#jls-14.14">14.14. The <code class="literal">for</code> Statement</a></span></dt>
               <dd>
                  <dl>
                     <dt><span class="section"><a href="jls-14.html#jls-14.14.1">14.14.1. The basic <code class="literal">for</code> Statement</a></span></dt>
                     <dd>
                        <dl>
                           <dt><span class="section"><a href="jls-14.html#jls-14.14.1.1">14.14.1.1. Initialization of <code class="literal">for</code> Statement</a></span></dt>
                           <dt><span class="section"><a href="jls-14.html#jls-14.14.1.2">14.14.1.2. Iteration of <code class="literal">for</code> Statement</a></span></dt>
                           <dt><span class="section"><a href="jls-14.html#jls-14.14.1.3">14.14.1.3. Abrupt Completion of <code class="literal">for</code> Statement</a></span></dt>
                        </dl>
                     </dd>
                     <dt><span class="section"><a href="jls-14.html#jls-14.14.2">14.14.2. The enhanced <code class="literal">for</code> statement</a></span></dt>
                  </dl>
               </dd>
               <dt><span class="section"><a href="jls-14.html#jls-14.15">14.15. The <code class="literal">break</code> Statement</a></span></dt>
               <dt><span class="section"><a href="jls-14.html#jls-14.16">14.16. The <code class="literal">continue</code> Statement</a></span></dt>
               <dt><span class="section"><a href="jls-14.html#jls-14.17">14.17. The <code class="literal">return</code> Statement</a></span></dt>
               <dt><span class="section"><a href="jls-14.html#jls-14.18">14.18. The <code class="literal">throw</code> Statement</a></span></dt>
               <dt><span class="section"><a href="jls-14.html#jls-14.19">14.19. The <code class="literal">synchronized</code> Statement</a></span></dt>
               <dt><span class="section"><a href="jls-14.html#jls-14.20">14.20. The <code class="literal">try</code> statement</a></span></dt>
               <dd>
                  <dl>
                     <dt><span class="section"><a href="jls-14.html#jls-14.20.1">14.20.1. Execution of <code class="literal">try</code>-<code class="literal">catch</code></a></span></dt>
                     <dt><span class="section"><a href="jls-14.html#jls-14.20.2">14.20.2. Execution of <code class="literal">try</code>-<code class="literal">finally</code> and <code class="literal">try</code>-<code class="literal">catch</code>-<code class="literal">finally</code></a></span></dt>
                     <dt><span class="section"><a href="jls-14.html#jls-14.20.3">14.20.3. <code class="literal">try</code>-with-resources</a></span></dt>
                     <dd>
                        <dl>
                           <dt><span class="section"><a href="jls-14.html#jls-14.20.3.1">14.20.3.1. Basic <code class="literal">try</code>-with-resources</a></span></dt>
                           <dt><span class="section"><a href="jls-14.html#jls-14.20.3.2">14.20.3.2. Extended <code class="literal">try</code>-with-resources</a></span></dt>
                        </dl>
                     </dd>
                  </dl>
               </dd>
               <dt><span class="section"><a href="jls-14.html#jls-14.21">14.21. Unreachable Statements</a></span></dt>
            </dl>
         </div>
         <p class="norm"><a name="jls-14-100"></a>The sequence of execution of a
            program is controlled by <span class="emphasis"><em>statements</em></span>, which are
            executed for their effect and do not have values.
         </p>
         <p class="norm"><a name="jls-14-110"></a>Some
            statements <span class="emphasis"><em>contain</em></span> other statements as part of
            their structure; such other statements are substatements of the
            statement. We say that
            statement <code class="varname">S</code> <span class="emphasis"><em>immediately
                  contains</em></span> statement <code class="varname">U</code> if there is no
            statement <code class="varname">T</code> different from <code class="varname">S</code>
            and <code class="varname">U</code> such that <code class="varname">S</code>
            contains <code class="varname">T</code> and <code class="varname">T</code>
            contains <code class="varname">U</code>. In the same manner, some statements
            contain expressions (<a class="xref" href="jls-15.html" title="Chapter&nbsp;15.&nbsp;Expressions">&sect;15 (<i>Expressions</i>)</a>) as part of their
            structure.
         </p>
         <p class="norm"><a name="jls-14-200"></a>The first section of this
            chapter discusses the distinction between normal and abrupt completion
            of statements (<a class="xref" href="jls-14.html#jls-14.1" title="14.1.&nbsp;Normal and Abrupt Completion of Statements">&sect;14.1</a>). Most of the remaining
            sections explain the various kinds of statements, describing in detail
            both their normal behavior and any special treatment of abrupt
            completion.
         </p>
         <p class="norm"><a name="jls-14-210"></a>Blocks are explained first
            (<a class="xref" href="jls-14.html#jls-14.2" title="14.2.&nbsp;Blocks">&sect;14.2</a>), followed by local class declarations
            (<a class="xref" href="jls-14.html#jls-14.3" title="14.3.&nbsp;Local Class Declarations">&sect;14.3</a>) and local variable declaration statements
            (<a class="xref" href="jls-14.html#jls-14.4" title="14.4.&nbsp;Local Variable Declaration Statements">&sect;14.4</a>).
         </p>
         <p class="norm"><a name="jls-14-220"></a>Next a grammatical maneuver that
            sidesteps the familiar "dangling else" problem
            (<a class="xref" href="jls-14.html#jls-14.5" title="14.5.&nbsp;Statements">&sect;14.5</a>) is explained.
         </p>
         <p class="norm"><a name="jls-14-230"></a>The last section
            (<a class="xref" href="jls-14.html#jls-14.21" title="14.21.&nbsp;Unreachable Statements">&sect;14.21</a>) of this chapter addresses the
            requirement that every statement be <span class="emphasis"><em>reachable</em></span> in
            a certain technical sense.
         </p>
         <div class="section" title="14.1.&nbsp;Normal and Abrupt Completion of Statements">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-14.1"></a>14.1.&nbsp;Normal and Abrupt Completion of Statements
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm-dynamic"><a name="jls-14.1-100"></a>Every
               statement has a normal mode of execution in which certain
               computational steps are carried out. The following sections describe
               the normal mode of execution for each kind of statement.
            </p>
            <p class="norm-dynamic"><a name="jls-14.1-110"></a>If all the
               steps are carried out as described, with no indication of abrupt
               completion, the statement is said to <span class="emphasis"><em>complete
                     normally</em></span>. However, certain events may prevent a statement
               from completing normally:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.1-110-A"></a>The
                            <code class="literal">break</code> (<a class="xref" href="jls-14.html#jls-14.15" title="14.15.&nbsp;The break Statement">&sect;14.15</a>), <code class="literal">continue</code>
                            (<a class="xref" href="jls-14.html#jls-14.16" title="14.16.&nbsp;The continue Statement">&sect;14.16</a>), and <code class="literal">return</code>
                            (<a class="xref" href="jls-14.html#jls-14.17" title="14.17.&nbsp;The return Statement">&sect;14.17</a>) statements cause a transfer of
                            control that may prevent normal completion of statements that
                            contain them.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.1-110-B"></a>Evaluation of certain expressions may
                            throw exceptions from the Java Virtual Machine (<a class="xref" href="jls-15.html#jls-15.6" title="15.6.&nbsp;Normal and Abrupt Completion of Evaluation">&sect;15.6</a>). An
                            explicit <code class="literal">throw</code> (<a class="xref" href="jls-14.html#jls-14.18" title="14.18.&nbsp;The throw Statement">&sect;14.18</a>) statement also
                            results in an exception. An exception causes a transfer of control
                            that may prevent normal completion of statements.
                     </p>
                  </li>
               </ul>
            </div>
            <p class="norm-dynamic"><a name="jls-14.1-120"></a>If such an
               event occurs, then execution of one or more statements may be
               terminated before all steps of their normal mode of execution have
               completed; such statements are said to <span class="emphasis"><em>complete
                     abruptly</em></span>.
            </p>
            <p class="norm-dynamic"><a name="jls-14.1-130"></a>An abrupt
               completion always has an associated <span class="emphasis"><em>reason</em></span>, which
               is one of the following:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.1-130-A"></a>A
                            <code class="literal">break</code> with no label
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.1-130-B"></a>A
                            <code class="literal">break</code> with a given label
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.1-130-C"></a>A
                            <code class="literal">continue</code> with no label
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.1-130-D"></a>A
                            <code class="literal">continue</code> with a given label
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.1-130-E"></a>A
                            <code class="literal">return</code> with no value
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.1-130-F"></a>A
                            <code class="literal">return</code> with a given value
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.1-130-G"></a>A
                            <code class="literal">throw</code> with a given value, including exceptions thrown by the
                            Java Virtual Machine
                     </p>
                  </li>
               </ul>
            </div>
            <p class="norm-dynamic"><a name="jls-14.1-140"></a>The terms
               "complete normally" and "complete abruptly" also apply to the
               evaluation of expressions (<a class="xref" href="jls-15.html#jls-15.6" title="15.6.&nbsp;Normal and Abrupt Completion of Evaluation">&sect;15.6</a>). The only
               reason an expression can complete abruptly is that an exception is
               thrown, because of either a <code class="literal">throw</code> with a given value
               (<a class="xref" href="jls-14.html#jls-14.18" title="14.18.&nbsp;The throw Statement">&sect;14.18</a>) or a run-time exception or error
               (<a class="xref" href="jls-11.html" title="Chapter&nbsp;11.&nbsp;Exceptions">&sect;11 (<i>Exceptions</i>)</a>, <a class="xref" href="jls-15.html#jls-15.6" title="15.6.&nbsp;Normal and Abrupt Completion of Evaluation">&sect;15.6</a>).
            </p>
            <p class="norm-dynamic"><a name="jls-14.1-150"></a>If a
               statement evaluates an expression, abrupt completion of the expression
               always causes the immediate abrupt completion of the statement, with
               the same reason. All succeeding steps in the normal mode of execution
               are not performed.
            </p>
            <p class="norm-dynamic"><a name="jls-14.1-160"></a>Unless
               otherwise specified in this chapter, abrupt completion of a
               substatement causes the immediate abrupt completion of the statement
               itself, with the same reason, and all succeeding steps in the normal
               mode of execution of the statement are not performed.
            </p>
            <p class="norm-dynamic"><a name="jls-14.1-170"></a>Unless
               otherwise specified, a statement completes normally if all expressions
               it evaluates and all substatements it executes complete
               normally.
            </p>
         </div>
         <div class="section" title="14.2.&nbsp;Blocks">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-14.2"></a>14.2.&nbsp;Blocks
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm-static"><a name="jls-14.2-100"></a>A <span class="emphasis"><em>block</em></span> is a sequence of
               statements, local class declarations, and local variable declaration
               statements within braces.
            </p>
            <div id="jls-14.2-110" class="productionset"><a name="jls-14.2-110"></a>
                 
               <div class="production"><a name="jls-Block"></a>
                      
                  <div class="lhs">Block:</div>
                      
                  <div class="rhs">
                           <code class="literal">{</code> [<a href="jls-14.html#jls-BlockStatements" title="BlockStatements">BlockStatements</a>] <code class="literal">}</code>
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-BlockStatements"></a>
                      
                  <div class="lhs">BlockStatements:</div>
                      
                  <div class="rhs">
                           <a href="jls-14.html#jls-BlockStatement" title="BlockStatement">BlockStatement</a> {<a href="jls-14.html#jls-BlockStatement" title="BlockStatement">BlockStatement</a>}
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-BlockStatement"></a>
                      
                  <div class="lhs">BlockStatement:</div>
                      
                  <div class="rhs">
                           <a href="jls-14.html#jls-LocalVariableDeclarationStatement" title="LocalVariableDeclarationStatement">LocalVariableDeclarationStatement</a> <br>
                           <a href="jls-8.html#jls-ClassDeclaration" title="ClassDeclaration">ClassDeclaration</a> <br>
                           <a href="jls-14.html#jls-Statement" title="Statement">Statement</a>
                         
                  </div>
                    
               </div>
               
            </div>
            <p class="norm-dynamic"><a name="jls-14.2-200"></a>A block is
               executed by executing each of the local variable declaration
               statements and other statements in order from first to last (left to
               right). If all of these block statements complete normally, then the
               block completes normally. If any of these block statements complete
               abruptly for any reason, then the block completes abruptly for the
               same reason.
            </p>
         </div>
         <div class="section" title="14.3.&nbsp;Local Class Declarations">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-14.3"></a>14.3.&nbsp;Local Class Declarations
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm-static"><a name="jls-14.3-100"></a>
               A <span class="emphasis"><em>local class</em></span> is a nested class
               (<a class="xref" href="jls-8.html" title="Chapter&nbsp;8.&nbsp;Classes">&sect;8 (<i>Classes</i>)</a>) that is not a member of any class and that
               has a name (<a class="xref" href="jls-6.html#jls-6.2" title="6.2.&nbsp;Names and Identifiers">&sect;6.2</a>,
               <a class="xref" href="jls-6.html#jls-6.7" title="6.7.&nbsp;Fully Qualified Names and Canonical Names">&sect;6.7</a>).
            </p>
            <p class="norm-static"><a name="jls-14.3-110"></a>All local
               classes are inner classes (<a class="xref" href="jls-8.html#jls-8.1.3" title="8.1.3.&nbsp;Inner Classes and Enclosing Instances">&sect;8.1.3</a>).
            </p>
            <p class="norm-static"><a name="jls-14.3-120"></a>Every local
               class declaration statement is immediately contained by a block
               (<a class="xref" href="jls-14.html#jls-14.2" title="14.2.&nbsp;Blocks">&sect;14.2</a>). Local class declaration statements may
               be intermixed freely with other kinds of statements in the
               block.
            </p>
            <p class="norm-error"><a name="jls-14.3-200"></a>It is a
               compile-time error if a local class declaration contains any of the
               access modifiers <code class="literal">public</code>, <code class="literal">protected</code>, or <code class="literal">private</code>
               (<a class="xref" href="jls-6.html#jls-6.6" title="6.6.&nbsp;Access Control">&sect;6.6</a>), or the modifier <code class="literal">static</code>
               (<a class="xref" href="jls-8.html#jls-8.1.1" title="8.1.1.&nbsp;Class Modifiers">&sect;8.1.1</a>).
            </p>
            <p class="norm-static"><a name="jls-14.3-300"></a>The scope and shadowing of a local
               class declaration is specified in <a class="xref" href="jls-6.html#jls-6.3" title="6.3.&nbsp;Scope of a Declaration">&sect;6.3</a> and
               <a class="xref" href="jls-6.html#jls-6.4" title="6.4.&nbsp;Shadowing and Obscuring">&sect;6.4</a>.
            </p>
            <div class="example"><a name="d5e19913"></a><p class="title"><b>Example&nbsp;14.3-1.&nbsp;Local Class Declarations</b></p>
               <div class="example-contents">
                  <p class="note">Here is an example that illustrates several aspects
                     of the rules given above:
                  </p><pre class="programlisting">
class Global {
    class Cyclic {}

    void foo() {
        new Cyclic(); // create a Global.Cyclic
        class Cyclic extends Cyclic {} // circular definition

        {
            class Local {}
            {
                class Local {} // compile-time error
            }
            class Local {} // compile-time error
            class AnotherLocal {
                void bar() {
                    class Local {} // ok
                }
            }
        }
        class Local {} // ok, not in scope of prior Local
    }
}
</pre><p class="note">The first statement of method <code class="literal">foo</code>
                     creates an instance of the member
                     class <code class="literal">Global.Cyclic</code> rather than an instance of the
                     local class <code class="literal">Cyclic</code>, because the statement appears
                     prior to the scope of the local class declaration.
                  </p>
                  <p class="note">The fact that the scope of a local class declaration
                     encompasses its whole declaration (not only its body) means that the
                     definition of the local class <code class="literal">Cyclic</code> is indeed
                     cyclic because it extends itself rather
                     than <code class="literal">Global.Cyclic</code>. Consequently, the declaration
                     of the local class <code class="literal">Cyclic</code> is rejected at compile
                     time.
                  </p>
                  <p class="note">Since local class names cannot be redeclared within
                     the same method (or constructor or initializer, as the case may be),
                     the second and third declarations of <code class="literal">Local</code> result
                     in compile-time errors. However, <code class="literal">Local</code> can be
                     redeclared in the context of another, more deeply nested, class such
                     as <code class="literal">AnotherLocal</code>.
                  </p>
                  <p class="note">The final declaration of <code class="literal">Local</code> is
                     legal, since it occurs outside the scope of any prior declaration
                     of <code class="literal">Local</code>.
                  </p>
               </div>
            </div><br class="example-break"></div>
         <div class="section" title="14.4.&nbsp;Local Variable Declaration Statements">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-14.4"></a>14.4.&nbsp;Local Variable Declaration Statements
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm-static"><a name="jls-14.4-100"></a>A <span class="emphasis"><em>local variable declaration
                     statement</em></span> declares one or more local variable names.
            </p>
            <div id="jls-14.4-110" class="productionset"><a name="jls-14.4-110"></a>
                 
               <div class="production"><a name="jls-LocalVariableDeclarationStatement"></a>
                      
                  <div class="lhs">LocalVariableDeclarationStatement:</div>
                      
                  <div class="rhs">
                           <a href="jls-14.html#jls-LocalVariableDeclaration" title="LocalVariableDeclaration">LocalVariableDeclaration</a> <code class="literal">;</code>
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-LocalVariableDeclaration"></a>
                      
                  <div class="lhs">LocalVariableDeclaration:</div>
                      
                  <div class="rhs">
                           {<a href="jls-8.html#jls-VariableModifier" title="VariableModifier">VariableModifier</a>}
                           <a href="jls-8.html#jls-UnannType" title="UnannType">UnannType</a>
                           <a href="jls-8.html#jls-VariableDeclaratorList" title="VariableDeclaratorList">VariableDeclaratorList</a>
                         
                  </div>
                    
               </div>
               
            </div>
            <p class="note">See <a class="xref" href="jls-8.html#jls-8.3" title="8.3.&nbsp;Field Declarations">&sect;8.3</a> for 
               <span class="emphasis"><em>UnannType</em></span>. The following productions from
               <a class="xref" href="jls-4.html#jls-4.3" title="4.3.&nbsp;Reference Types and Values">&sect;4.3</a>, <a class="xref" href="jls-8.html#jls-8.4.1" title="8.4.1.&nbsp;Formal Parameters">&sect;8.4.1</a>, and
               <a class="xref" href="jls-8.html#jls-8.3" title="8.3.&nbsp;Field Declarations">&sect;8.3</a> are shown here for convenience:
            </p>
            <div id="d5e19954" class="productionset"><a name="d5e19954"></a>
                 
               <div class="productionrecap-note">
                  <div class="production">
                         
                     <div class="lhs">VariableModifier:</div>
                         
                     <div class="rhs">
                              <a href="jls-9.html#jls-Annotation" title="Annotation">Annotation</a> <code class="literal">final</code>
                            
                     </div>
                       
                  </div>
               </div>
                 
               <div class="productionrecap-note">
                  <div class="production">
                         
                     <div class="lhs">VariableDeclaratorList:</div>
                         
                     <div class="rhs">
                              <a href="jls-8.html#jls-VariableDeclarator" title="VariableDeclarator">VariableDeclarator</a> {<code class="literal">,</code> <a href="jls-8.html#jls-VariableDeclarator" title="VariableDeclarator">VariableDeclarator</a>}
                            
                     </div>
                       
                  </div>
               </div>
                 
               <div class="productionrecap-note">
                  <div class="production">
                         
                     <div class="lhs">VariableDeclarator:</div>
                         
                     <div class="rhs">
                              <a href="jls-8.html#jls-VariableDeclaratorId" title="VariableDeclaratorId">VariableDeclaratorId</a> [<code class="literal">=</code> <a href="jls-8.html#jls-VariableInitializer" title="VariableInitializer">VariableInitializer</a>]
                            
                     </div>
                       
                  </div>
               </div>
                 
               <div class="productionrecap-note">
                  <div class="production">
                         
                     <div class="lhs">VariableDeclaratorId:</div>
                         
                     <div class="rhs">
                              <a href="jls-3.html#jls-Identifier" title="Identifier">Identifier</a> [<a href="jls-4.html#jls-Dims" title="Dims">Dims</a>]
                            
                     </div>
                       
                  </div>
               </div>
                 
               <div class="productionrecap-note">
                  <div class="production">
                         
                     <div class="lhs">Dims:</div>
                         
                     <div class="rhs">
                              {<a href="jls-9.html#jls-Annotation" title="Annotation">Annotation</a>} <code class="literal">[</code> <code class="literal">]</code> {{<a href="jls-9.html#jls-Annotation" title="Annotation">Annotation</a>} <code class="literal">[</code> <code class="literal">]</code>}
                            
                     </div>
                       
                  </div>
               </div>
                 
               <div class="productionrecap-note">
                  <div class="production">
                         
                     <div class="lhs">VariableInitializer:</div>
                         
                     <div class="rhs">
                              <a href="jls-15.html#jls-Expression" title="Expression">Expression</a> <br>
                              <a href="jls-10.html#jls-ArrayInitializer" title="ArrayInitializer">ArrayInitializer</a>
                            
                     </div>
                       
                  </div>
               </div>
               
            </div>
            <p class="norm-static"><a name="jls-14.4-200"></a>Every local
               variable declaration statement is immediately contained by a
               block. Local variable declaration statements may be intermixed freely
               with other kinds of statements in the block.
            </p>
            <p class="norm-static"><a name="jls-14.4-210"></a>Apart from
               local variable declaration statements, a local variable declaration
               can appear in the header of a <code class="literal">for</code> statement
               (<a class="xref" href="jls-14.html#jls-14.14" title="14.14.&nbsp;The for Statement">&sect;14.14</a>) or <code class="literal">try</code>-with-resources statement
               (<a class="xref" href="jls-14.html#jls-14.20.3" title="14.20.3.&nbsp;try-with-resources">&sect;14.20.3</a>). In these cases, it is executed in the
               same manner as if it were part of a local variable declaration
               statement.
            </p>
            <p class="norm-error"><a name="jls-14.4-300"></a>The rules for
               annotation modifiers on a local variable declaration are specified in
               <a class="xref" href="jls-9.html#jls-9.7.4" title="9.7.4.&nbsp;Where Annotations May Appear">&sect;9.7.4</a> and <a class="xref" href="jls-9.html#jls-9.7.5" title="9.7.5.&nbsp;Multiple Annotations Of The Same Type">&sect;9.7.5</a>.
            </p>
            <p class="norm-error"><a name="jls-14.4-310"></a>It is a
               compile-time error if <code class="literal">final</code> appears more than once as a modifier for
               a local variable declaration.
            </p>
            <div class="section" title="14.4.1.&nbsp;Local Variable Declarators and Types">
               <div class="titlepage">
                  <div>
                     <div>
                        <h3 class="title"><a name="jls-14.4.1"></a>14.4.1.&nbsp;Local Variable Declarators and Types
                        </h3>
                     </div>
                  </div>
               </div>
               <p class="norm-static"><a name="jls-14.4.1-100"></a>Each
                  <span class="emphasis"><em>declarator</em></span> in a local variable declaration
                  declares one local variable, whose name is the <span class="emphasis"><em>Identifier</em></span> that
                  appears in the declarator.
               </p>
               <p class="norm-static"><a name="jls-14.4.1-110"></a>If the
                  optional keyword <code class="literal">final</code> appears at the start of the declaration, the
                  variable being declared is a final variable
                  (<a class="xref" href="jls-4.html#jls-4.12.4" title="4.12.4.&nbsp;final Variables">&sect;4.12.4</a>).
               </p>
               <p class="norm-static"><a name="jls-14.4.1-200"></a>The declared
                  type of a local variable is denoted by
                  the <span class="emphasis"><em>UnannType</em></span> that appears in the local variable
                  declaration, followed by any bracket pairs that follow the
                  <span class="emphasis"><em>Identifier</em></span> in the declarator.
               </p>
               <p class="norm-dynamic"><a name="jls-14.4.1-210"></a>A local
                  variable of type <code class="literal">float</code> always contains a value that is an element of
                  the float value set (<a class="xref" href="jls-4.html#jls-4.2.3" title="4.2.3.&nbsp;Floating-Point Types, Formats, and Values">&sect;4.2.3</a>); similarly, a local
                  variable of type <code class="literal">double</code> always contains a value that is an element
                  of the double value set. It is not permitted for a local variable of
                  type <code class="literal">float</code> to contain an element of the float-extended-exponent
                  value set that is not also an element of the float value set, nor for
                  a local variable of type <code class="literal">double</code> to contain an element of the
                  double-extended-exponent value set that is not also an element of the
                  double value set.
               </p>
               <p class="norm-static"><a name="jls-14.4.1-220"></a>The scope and shadowing of a local
                  variable is specified in <a class="xref" href="jls-6.html#jls-6.3" title="6.3.&nbsp;Scope of a Declaration">&sect;6.3</a> and
                  <a class="xref" href="jls-6.html#jls-6.4" title="6.4.&nbsp;Shadowing and Obscuring">&sect;6.4</a>.
               </p>
            </div>
            <div class="section" title="14.4.2.&nbsp;Execution of Local Variable Declarations">
               <div class="titlepage">
                  <div>
                     <div>
                        <h3 class="title"><a name="jls-14.4.2"></a>14.4.2.&nbsp;Execution of Local Variable Declarations
                        </h3>
                     </div>
                  </div>
               </div>
               <p class="norm-dynamic"><a name="jls-14.4.2-100"></a>A local
                  variable declaration statement is an executable statement. Every time
                  it is executed, the declarators are processed in order from left to
                  right. If a declarator has an initializer, the initializer is
                  evaluated and its value is assigned to the variable.
               </p>
               <p class="note">If a declarator does not have an initializer, then
                  every reference to the variable must be preceded by execution of an
                  assignment to the variable, or a compile-time error occurs by the
                  rules of <a class="xref" href="jls-16.html" title="Chapter&nbsp;16.&nbsp;Definite Assignment">&sect;16 (<i>Definite Assignment</i>)</a>.
               </p>
               <p class="norm-dynamic"><a name="jls-14.4.2-110"></a>Each
                  initializer (except the first) is evaluated only if evaluation of the
                  preceding initializer completes normally.
               </p>
               <p class="norm-dynamic"><a name="jls-14.4.2-120"></a>Execution of the local variable declaration
                  completes normally only if evaluation of the last initializer
                  completes normally.
               </p>
               <p class="norm-dynamic"><a name="jls-14.4.2-130"></a>If the
                  local variable declaration contains no initializers, then executing it
                  always completes normally.
               </p>
            </div>
         </div>
         <div class="section" title="14.5.&nbsp;Statements">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-14.5"></a>14.5.&nbsp;Statements
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm"><a name="jls-14.5-100"></a>There are many kinds of
               statements in the Java programming language. Most correspond to statements in the C
               and C++ languages, but some are unique.
            </p>
            <p class="norm"><a name="jls-14.5-110"></a>As in C and C++, the <code class="literal">if</code>
               statement of the Java programming language suffers from the so-called "dangling
               <code class="literal">else</code> problem," illustrated by this misleadingly formatted
               example:
            </p><pre class="screen">
if (door.isOpen())
    if (resident.isVisible())
        resident.greet("Hello!");
else door.bell.ring();  // A "dangling else"
</pre><p class="norm"><a name="jls-14.5-120"></a>The problem is that both the
               outer <code class="literal">if</code> statement and the inner <code class="literal">if</code> statement might conceivably
               own the <code class="literal">else</code> clause. In this example, one might surmise that the
               programmer intended the <code class="literal">else</code> clause to belong to the outer <code class="literal">if</code>
               statement.
            </p>
            <p class="norm"><a name="jls-14.5-130"></a>The Java programming language, like C and C++
               and many programming languages before them, arbitrarily decrees that
               an <code class="literal">else</code> clause belongs to the innermost <code class="literal">if</code> to which it might
               possibly belong. This rule is captured by the following
               grammar:
            </p>
            <div id="jls-14.5-140" class="productionset"><a name="jls-14.5-140"></a>
                 
               <div class="production"><a name="jls-Statement"></a>
                      
                  <div class="lhs">Statement:</div>
                      
                  <div class="rhs">
                           <a href="jls-14.html#jls-StatementWithoutTrailingSubstatement" title="StatementWithoutTrailingSubstatement">StatementWithoutTrailingSubstatement</a> <br>
                           <a href="jls-14.html#jls-LabeledStatement" title="LabeledStatement">LabeledStatement</a> <br>
                           <a href="jls-14.html#jls-IfThenStatement" title="IfThenStatement">IfThenStatement</a> <br>
                           <a href="jls-14.html#jls-IfThenElseStatement" title="IfThenElseStatement">IfThenElseStatement</a> <br>
                           <a href="jls-14.html#jls-WhileStatement" title="WhileStatement">WhileStatement</a> <br>
                           <a href="jls-14.html#jls-ForStatement" title="ForStatement">ForStatement</a>
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-StatementNoShortIf"></a>
                      
                  <div class="lhs">StatementNoShortIf:</div>
                      
                  <div class="rhs">
                           <a href="jls-14.html#jls-StatementWithoutTrailingSubstatement" title="StatementWithoutTrailingSubstatement">StatementWithoutTrailingSubstatement</a> <br>
                           <a href="jls-14.html#jls-LabeledStatementNoShortIf" title="LabeledStatementNoShortIf">LabeledStatementNoShortIf</a> <br>
                           <a href="jls-14.html#jls-IfThenElseStatementNoShortIf" title="IfThenElseStatementNoShortIf">IfThenElseStatementNoShortIf</a> <br>
                           <a href="jls-14.html#jls-WhileStatementNoShortIf" title="WhileStatementNoShortIf">WhileStatementNoShortIf</a> <br>
                           <a href="jls-14.html#jls-ForStatementNoShortIf" title="ForStatementNoShortIf">ForStatementNoShortIf</a>
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-StatementWithoutTrailingSubstatement"></a>
                      
                  <div class="lhs">StatementWithoutTrailingSubstatement:</div>
                      
                  <div class="rhs">
                           <a href="jls-14.html#jls-Block" title="Block">Block</a> <br>
                           <a href="jls-14.html#jls-EmptyStatement" title="EmptyStatement">EmptyStatement</a> <br>
                           <a href="jls-14.html#jls-ExpressionStatement" title="ExpressionStatement">ExpressionStatement</a> <br>
                           <a href="jls-14.html#jls-AssertStatement" title="AssertStatement">AssertStatement</a> <br>
                           <a href="jls-14.html#jls-SwitchStatement" title="SwitchStatement">SwitchStatement</a> <br>
                           <a href="jls-14.html#jls-DoStatement" title="DoStatement">DoStatement</a> <br>
                           <a href="jls-14.html#jls-BreakStatement" title="BreakStatement">BreakStatement</a> <br>
                           <a href="jls-14.html#jls-ContinueStatement" title="ContinueStatement">ContinueStatement</a> <br>
                           <a href="jls-14.html#jls-ReturnStatement" title="ReturnStatement">ReturnStatement</a> <br>
                           <a href="jls-14.html#jls-SynchronizedStatement" title="SynchronizedStatement">SynchronizedStatement</a> <br>
                           <a href="jls-14.html#jls-ThrowStatement" title="ThrowStatement">ThrowStatement</a> <br>
                           <a href="jls-14.html#jls-TryStatement" title="TryStatement">TryStatement</a>
                         
                  </div>
                    
               </div>
               
            </div>
            <p class="note">The following productions from
               <a class="xref" href="jls-14.html#jls-14.9" title="14.9.&nbsp;The if Statement">&sect;14.9</a> are shown here for convenience:
            </p>
            <div id="d5e20051" class="productionset"><a name="d5e20051"></a>
                 
               <div class="productionrecap-note">
                  <div class="production">
                         
                     <div class="lhs">IfThenStatement:</div>
                         
                     <div class="rhs">
                              <code class="literal">if</code> <code class="literal">(</code> <a href="jls-15.html#jls-Expression" title="Expression">Expression</a> <code class="literal">)</code>
                              <a href="jls-14.html#jls-Statement" title="Statement">Statement</a>
                            
                     </div>
                       
                  </div>
               </div>
                 
               <div class="productionrecap-note">
                  <div class="production">
                         
                     <div class="lhs">IfThenElseStatement:</div>
                         
                     <div class="rhs">
                              <code class="literal">if</code> <code class="literal">(</code> <a href="jls-15.html#jls-Expression" title="Expression">Expression</a> <code class="literal">)</code>
                              <a href="jls-14.html#jls-StatementNoShortIf" title="StatementNoShortIf">StatementNoShortIf</a>
                              <code class="literal">else</code> <a href="jls-14.html#jls-Statement" title="Statement">Statement</a>
                            
                     </div>
                       
                  </div>
               </div>
                 
               <div class="productionrecap-note">
                  <div class="production">
                         
                     <div class="lhs">IfThenElseStatementNoShortIf:</div>
                         
                     <div class="rhs">
                              <code class="literal">if</code> <code class="literal">(</code> <a href="jls-15.html#jls-Expression" title="Expression">Expression</a> <code class="literal">)</code>
                              <a href="jls-14.html#jls-StatementNoShortIf" title="StatementNoShortIf">StatementNoShortIf</a>
                              <code class="literal">else</code> <a href="jls-14.html#jls-StatementNoShortIf" title="StatementNoShortIf">StatementNoShortIf</a>
                            
                     </div>
                       
                  </div>
               </div>
               
            </div>
            <p class="norm"><a name="jls-14.5-150"></a>Statements are thus
               grammatically divided into two categories: those that might end in an
               <code class="literal">if</code> statement that has no <code class="literal">else</code> clause (a "short <code class="literal">if</code> statement")
               and those that definitely do not.
            </p>
            <p class="norm"><a name="jls-14.5-160"></a>Only statements that
               definitely do not end in a short <code class="literal">if</code> statement may appear as an
               immediate substatement before the keyword <code class="literal">else</code> in an <code class="literal">if</code> statement
               that does have an <code class="literal">else</code> clause.
            </p>
            <p class="norm"><a name="jls-14.5-170"></a>This simple rule prevents the
               "dangling <code class="literal">else</code>" problem. The execution behavior of a statement with
               the "no short <code class="literal">if</code>" restriction is identical to the execution behavior
               of the same kind of statement without the "no short <code class="literal">if</code>" restriction;
               the distinction is drawn purely to resolve the syntactic
               difficulty.
            </p>
         </div>
         <div class="section" title="14.6.&nbsp;The Empty Statement">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-14.6"></a>14.6.&nbsp;The Empty Statement
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm-dynamic"><a name="jls-14.6-100"></a>An empty
               statement does nothing.
            </p>
            <div id="jls-14.6-110" class="productionset"><a name="jls-14.6-110"></a>
                 
               <div class="production"><a name="jls-EmptyStatement"></a>
                      
                  <div class="lhs">EmptyStatement:</div>
                      
                  <div class="rhs">
                           <code class="literal">;</code>
                         
                  </div>
                    
               </div>
               
            </div>
            <p class="norm-dynamic"><a name="jls-14.6-200"></a>Execution
               of an empty statement always completes normally.
            </p>
         </div>
         <div class="section" title="14.7.&nbsp;Labeled Statements">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-14.7"></a>14.7.&nbsp;Labeled Statements
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm-static"><a name="jls-14.7-100"></a>Statements
               may have <span class="emphasis"><em>label</em></span> prefixes.
            </p>
            <div id="jls-14.7-110" class="productionset"><a name="jls-14.7-110"></a>
                 
               <div class="production"><a name="jls-LabeledStatement"></a>
                      
                  <div class="lhs">LabeledStatement:</div>
                      
                  <div class="rhs">
                           <a href="jls-3.html#jls-Identifier" title="Identifier">Identifier</a> <code class="literal">:</code>
                           <a href="jls-14.html#jls-Statement" title="Statement">Statement</a>
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-LabeledStatementNoShortIf"></a>
                      
                  <div class="lhs">LabeledStatementNoShortIf:</div>
                      
                  <div class="rhs">
                           <a href="jls-3.html#jls-Identifier" title="Identifier">Identifier</a> <code class="literal">:</code>
                           <a href="jls-14.html#jls-StatementNoShortIf" title="StatementNoShortIf">StatementNoShortIf</a>
                         
                  </div>
                    
               </div>
               
            </div>
            <p class="norm-static"><a name="jls-14.7-120"></a>The
               <span class="emphasis"><em>Identifier</em></span> is declared to be the label of the immediately contained
               <span class="emphasis"><em>Statement</em></span>.
            </p>
            <p class="norm"><a name="jls-14.7-130"></a>Unlike C and C++, the
               Java programming language has no <code class="literal">goto</code> statement; identifier
               statement labels are used with <code class="literal">break</code> or <code class="literal">continue</code> statements
               (<a class="xref" href="jls-14.html#jls-14.15" title="14.15.&nbsp;The break Statement">&sect;14.15</a>, <a class="xref" href="jls-14.html#jls-14.16" title="14.16.&nbsp;The continue Statement">&sect;14.16</a>) appearing
               anywhere within the labeled statement.
            </p>
            <p class="norm-static"><a name="jls-14.7-200"></a>The scope
               of a label of a labeled statement is the immediately contained
               <span class="emphasis"><em>Statement</em></span>.
            </p>
            <p class="norm-error"><a name="jls-14.7-210"></a>It is a compile-time error if the
               name of a label of a labeled statement is used within the scope of the
               label as a label of another labeled statement.
            </p>
            <p class="norm-static"><a name="jls-14.7-220"></a>There is no
               restriction against using the same identifier as a label and as the
               name of a package, class, interface, method, field, parameter, or
               local variable. Use of an identifier to label a statement does not
               obscure (<a class="xref" href="jls-6.html#jls-6.4.2" title="6.4.2.&nbsp;Obscuring">&sect;6.4.2</a>) a package, class, interface,
               method, field, parameter, or local variable with the same name. Use of
               an identifier as a class, interface, method, field, local variable or
               as the parameter of an exception handler (<a class="xref" href="jls-14.html#jls-14.20" title="14.20.&nbsp;The try statement">&sect;14.20</a>)
               does not obscure a statement label with the same name.
            </p>
            <p class="norm-dynamic"><a name="jls-14.7-300"></a>A labeled
               statement is executed by executing the immediately contained
               <span class="emphasis"><em>Statement</em></span>.
            </p>
            <p class="norm-dynamic"><a name="jls-14.7-310"></a>If the
               statement is labeled by an <span class="emphasis"><em>Identifier</em></span> and the contained <span class="emphasis"><em>Statement</em></span>
               completes abruptly because of a <code class="literal">break</code> with the same <span class="emphasis"><em>Identifier</em></span>,
               then the labeled statement completes normally. In all other cases of
               abrupt completion of the <span class="emphasis"><em>Statement</em></span>, the labeled statement completes
               abruptly for the same reason.
            </p>
            <div class="example"><a name="d5e20117"></a><p class="title"><b>Example&nbsp;14.7-1.&nbsp;Labels and Identifiers</b></p>
               <div class="example-contents">
                  <p class="note">The following code was taken from a version of the
                     class <code class="literal">String</code> and its method <code class="literal">indexOf</code>, where the
                     label was originally called <code class="literal">test</code>. Changing the
                     label to have the same name as the local variable <code class="literal">i</code>
                     does not obscure the label in the scope of the declaration
                     of <code class="literal">i</code>. Thus, the code is valid.
                  </p><pre class="programlisting">
class Test {
    char[] value;
    int offset, count;
    int indexOf(TestString str, int fromIndex) {
        char[] v1 = value, v2 = str.value;
        int max = offset + (count - str.count);
        int start = offset + ((fromIndex &lt; 0) ? 0 : fromIndex);
    i:
        for (int i = start; i &lt;= max; i++) {
            int n = str.count, j = i, k = str.offset;
            while (n-- != 0) {
                if (v1[j++] != v2[k++])
                    continue i;
            } 
            return i - offset;
        }
        return -1;
    }
}
</pre><p class="note">The identifier <code class="literal">max</code> could also
                     have been used as the statement label; the label would not obscure the
                     local variable <code class="literal">max</code> within the labeled
                     statement.
                  </p>
               </div>
            </div><br class="example-break"></div>
         <div class="section" title="14.8.&nbsp;Expression Statements">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-14.8"></a>14.8.&nbsp;Expression Statements
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm-static"><a name="jls-14.8-100"></a>Certain
               kinds of expressions may be used as statements by following them with
               semicolons.
            </p>
            <div id="jls-14.8-110" class="productionset"><a name="jls-14.8-110"></a>
                 
               <div class="production"><a name="jls-ExpressionStatement"></a>
                      
                  <div class="lhs">ExpressionStatement:</div>
                      
                  <div class="rhs">
                           <a href="jls-14.html#jls-StatementExpression" title="StatementExpression">StatementExpression</a> <code class="literal">;</code>
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-StatementExpression"></a>
                      
                  <div class="lhs">StatementExpression:</div>
                      
                  <div class="rhs">
                           <a href="jls-15.html#jls-Assignment" title="Assignment">Assignment</a> <br>
                           <a href="jls-15.html#jls-PreIncrementExpression" title="PreIncrementExpression">PreIncrementExpression</a> <br>
                           <a href="jls-15.html#jls-PreDecrementExpression" title="PreDecrementExpression">PreDecrementExpression</a> <br>
                           <a href="jls-15.html#jls-PostIncrementExpression" title="PostIncrementExpression">PostIncrementExpression</a> <br>
                           <a href="jls-15.html#jls-PostDecrementExpression" title="PostDecrementExpression">PostDecrementExpression</a> <br>
                           <a href="jls-15.html#jls-MethodInvocation" title="MethodInvocation">MethodInvocation</a> <br>
                           <a href="jls-15.html#jls-ClassInstanceCreationExpression" title="ClassInstanceCreationExpression">ClassInstanceCreationExpression</a>
                         
                  </div>
                    
               </div>
               
            </div>
            <p class="norm-dynamic"><a name="jls-14.8-200"></a>An <span class="emphasis"><em>expression statement</em></span> is
               executed by evaluating the expression; if the expression has a value,
               the value is discarded.
            </p>
            <p class="norm-dynamic"><a name="jls-14.8-210"></a>Execution
               of the expression statement completes normally if and only if
               evaluation of the expression completes normally.
            </p>
            <p class="note">Unlike C and C++, the Java programming language allows only certain
               forms of expressions to be used as expression statements. Note that
               the Java programming language does not allow a "cast to <code class="literal">void</code>" - <code class="literal">void</code> is not a
               type - so the traditional C trick of writing an expression statement
               such as:
            </p><pre class="screen">
(void)... ;  // incorrect!
</pre><p class="note">does not work. On the other hand, the Java programming language
               allows all the most useful kinds of expressions in expression
               statements, and it does not require a method invocation used as an
               expression statement to invoke a <code class="literal">void</code> method, so such a trick is
               almost never needed. If a trick is needed, either an assignment
               statement (<a class="xref" href="jls-15.html#jls-15.26" title="15.26.&nbsp;Assignment Operators">&sect;15.26</a>) or a local variable
               declaration statement (<a class="xref" href="jls-14.html#jls-14.4" title="14.4.&nbsp;Local Variable Declaration Statements">&sect;14.4</a>) can be used
               instead.
            </p>
         </div>
         <div class="section" title="14.9.&nbsp;The if Statement">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-14.9"></a>14.9.&nbsp;The <code class="literal">if</code> Statement
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm-dynamic"><a name="jls-14.9-100"></a>The <code class="literal">if</code>
               statement allows conditional execution of a statement or a conditional
               choice of two statements, executing one or the other but not
               both.
            </p>
            <div id="jls-14.9-110" class="productionset"><a name="jls-14.9-110"></a>
                 
               <div class="production"><a name="jls-IfThenStatement"></a>
                      
                  <div class="lhs">IfThenStatement:</div>
                      
                  <div class="rhs">
                           <code class="literal">if</code> <code class="literal">(</code> <a href="jls-15.html#jls-Expression" title="Expression">Expression</a> <code class="literal">)</code>
                           <a href="jls-14.html#jls-Statement" title="Statement">Statement</a>
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-IfThenElseStatement"></a>
                      
                  <div class="lhs">IfThenElseStatement:</div>
                      
                  <div class="rhs">
                           <code class="literal">if</code> <code class="literal">(</code> <a href="jls-15.html#jls-Expression" title="Expression">Expression</a> <code class="literal">)</code>
                           <a href="jls-14.html#jls-StatementNoShortIf" title="StatementNoShortIf">StatementNoShortIf</a>
                           <code class="literal">else</code> <a href="jls-14.html#jls-Statement" title="Statement">Statement</a>
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-IfThenElseStatementNoShortIf"></a>
                      
                  <div class="lhs">IfThenElseStatementNoShortIf:</div>
                      
                  <div class="rhs">
                           <code class="literal">if</code> <code class="literal">(</code> <a href="jls-15.html#jls-Expression" title="Expression">Expression</a> <code class="literal">)</code>
                           <a href="jls-14.html#jls-StatementNoShortIf" title="StatementNoShortIf">StatementNoShortIf</a>
                           <code class="literal">else</code> <a href="jls-14.html#jls-StatementNoShortIf" title="StatementNoShortIf">StatementNoShortIf</a>
                         
                  </div>
                    
               </div>
               
            </div>
            <p class="norm-error"><a name="jls-14.9-200"></a>The
               <span class="emphasis"><em>Expression</em></span> must have type <code class="literal">boolean</code> or <code class="literal">Boolean</code>, or a compile-time
               error occurs.
            </p>
            <div class="section" title="14.9.1.&nbsp;The if-then Statement">
               <div class="titlepage">
                  <div>
                     <div>
                        <h3 class="title"><a name="jls-14.9.1"></a>14.9.1.&nbsp;The <code class="literal">if</code>-<code class="literal">then</code> Statement
                        </h3>
                     </div>
                  </div>
               </div>
               <p class="norm-dynamic"><a name="jls-14.9.1-100"></a>An
                  <code class="literal">if</code>-<code class="literal">then</code> statement is executed by first evaluating the
                  <span class="emphasis"><em>Expression</em></span>. If the result is of type <code class="literal">Boolean</code>, it is subject to
                  unboxing conversion (<a class="xref" href="jls-5.html#jls-5.1.8" title="5.1.8.&nbsp;Unboxing Conversion">&sect;5.1.8</a>).
               </p>
               <p class="norm-dynamic"><a name="jls-14.9.1-110"></a>If
                  evaluation of the <span class="emphasis"><em>Expression</em></span> or the subsequent unboxing conversion
                  (if any) completes abruptly for some reason, the <code class="literal">if</code>-<code class="literal">then</code> statement
                  completes abruptly for the same reason.
               </p>
               <p class="norm-dynamic"><a name="jls-14.9.1-120"></a>Otherwise, execution continues by making a
                  choice based on the resulting value:
               </p>
               <div class="norm">
                  <ul class="norm" type="disc">
                     <li class="listitem">
                        <p class="norm-dynamic"><a name="jls-14.9.1-120-A"></a>If
                                 the value is <code class="literal">true</code>, then the contained <span class="emphasis"><em>Statement</em></span> is executed;
                                 the <code class="literal">if</code>-<code class="literal">then</code> statement completes normally if and only if
                                 execution of the <span class="emphasis"><em>Statement</em></span> completes normally.
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="norm-dynamic"><a name="jls-14.9.1-120-B"></a>If
                                 the value is <code class="literal">false</code>, no further action is taken and the
                                 <code class="literal">if</code>-<code class="literal">then</code> statement completes normally.
                        </p>
                     </li>
                  </ul>
               </div>
            </div>
            <div class="section" title="14.9.2.&nbsp;The if-then-else Statement">
               <div class="titlepage">
                  <div>
                     <div>
                        <h3 class="title"><a name="jls-14.9.2"></a>14.9.2.&nbsp;The <code class="literal">if</code>-<code class="literal">then</code>-<code class="literal">else</code> Statement
                        </h3>
                     </div>
                  </div>
               </div>
               <p class="norm-dynamic"><a name="jls-14.9.2-100"></a>An
                  <code class="literal">if</code>-<code class="literal">then</code>-<code class="literal">else</code> statement is executed by first evaluating the
                  <span class="emphasis"><em>Expression</em></span>. If the result is of type <code class="literal">Boolean</code>, it is subject to
                  unboxing conversion (<a class="xref" href="jls-5.html#jls-5.1.8" title="5.1.8.&nbsp;Unboxing Conversion">&sect;5.1.8</a>).
               </p>
               <p class="norm-dynamic"><a name="jls-14.9.2-110"></a>If
                  evaluation of the <span class="emphasis"><em>Expression</em></span> or the subsequent unboxing conversion
                  (if any) completes abruptly for some reason, then the
                  <code class="literal">if</code>-<code class="literal">then</code>-<code class="literal">else</code> statement completes abruptly for the same
                  reason.
               </p>
               <p class="norm-dynamic"><a name="jls-14.9.2-120"></a>Otherwise, execution continues by making a
                  choice based on the resulting value:
               </p>
               <div class="norm">
                  <ul class="norm" type="disc">
                     <li class="listitem">
                        <p class="norm-dynamic"><a name="jls-14.9.2-120-A"></a>If
                               the value is <code class="literal">true</code>, then the first contained <span class="emphasis"><em>Statement</em></span> (the one
                               before the <code class="literal">else</code> keyword) is executed; the <code class="literal">if</code>-<code class="literal">then</code>-<code class="literal">else</code>
                               statement completes normally if and only if execution of that
                               statement completes normally.
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="norm-dynamic"><a name="jls-14.9.2-120-B"></a>If
                               the value is <code class="literal">false</code>, then the second contained <span class="emphasis"><em>Statement</em></span> (the
                               one after the <code class="literal">else</code> keyword) is executed; the <code class="literal">if</code>-<code class="literal">then</code>-<code class="literal">else</code>
                               statement completes normally if and only if execution of that
                               statement completes normally.
                        </p>
                     </li>
                  </ul>
               </div>
            </div>
         </div>
         <div class="section" title="14.10.&nbsp;The assert Statement">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-14.10"></a>14.10.&nbsp;The <code class="literal">assert</code> Statement
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm"><a name="jls-14.10-100"></a>An
               <span class="emphasis"><em>assertion</em></span> is an <code class="literal">assert</code> statement containing a
               boolean expression. An assertion is either
               <span class="emphasis"><em>enabled</em></span> or <span class="emphasis"><em>disabled</em></span>. If an
               assertion is enabled, execution of the assertion causes evaluation of
               the boolean expression and an error is reported if the expression
               evaluates to <code class="literal">false</code>. If the assertion is disabled, execution of the
               assertion has no effect whatsoever.
            </p>
            <div id="jls-14.10-110" class="productionset"><a name="jls-14.10-110"></a>
                 
               <div class="production"><a name="jls-AssertStatement"></a>
                      
                  <div class="lhs">AssertStatement:</div>
                      
                  <div class="rhs">
                           <code class="literal">assert</code> <a href="jls-15.html#jls-Expression" title="Expression">Expression</a> <code class="literal">;</code> <br>
                           <code class="literal">assert</code> <a href="jls-15.html#jls-Expression" title="Expression">Expression</a> <code class="literal">:</code> <a href="jls-15.html#jls-Expression" title="Expression">Expression</a> <code class="literal">;</code>
                         
                  </div>
                    
               </div>
               
            </div>
            <p class="norm"><a name="jls-14.10-120"></a>To ease the presentation, the
               first <span class="emphasis"><em>Expression</em></span> in both forms of the <code class="literal">assert</code> statement is referred
               to as <span class="emphasis"><em>Expression1</em></span>. In the second form of the
               <code class="literal">assert</code> statement, the second <span class="emphasis"><em>Expression</em></span> is referred to
               as <span class="emphasis"><em>Expression2</em></span>.
            </p>
            <p class="norm-error"><a name="jls-14.10-200"></a>It is a
               compile-time error if <span class="emphasis"><em>Expression1</em></span> does not have
               type <code class="literal">boolean</code> or <code class="literal">Boolean</code>.
            </p>
            <p class="norm-error"><a name="jls-14.10-210"></a>In the
               second form of the <code class="literal">assert</code> statement, it is a compile-time error if
               <span class="emphasis"><em>Expression2</em></span> is void (<a class="xref" href="jls-15.html#jls-15.1" title="15.1.&nbsp;Evaluation, Denotation, and Result">&sect;15.1</a>).
            </p>
            <p class="norm-dynamic"><a name="jls-14.10-300"></a>An <code class="literal">assert</code>
               statement that is executed after its class has completed
               initialization is enabled if and only if the host system has
               determined that the top level class that lexically contains the
               <code class="literal">assert</code> statement enables assertions.
            </p>
            <p class="norm-dynamic"><a name="jls-14.10-310"></a>Whether or
               not a top level class enables assertions is determined no later than
               the earliest of the initialization of the top level class and the
               initialization of any class nested in the top level class, and cannot
               be changed after it has been determined.
            </p>
            <p class="norm-dynamic"><a name="jls-14.10-320"></a>An <code class="literal">assert</code>
               statement that is executed before its class has completed
               initialization is enabled.
            </p>
            <div class="informalexample">
               <p class="note">This rule is
                  motivated by a case that demands special treatment. Recall that the
                  assertion status of a class is set no later
                  than the time it is initialized. It is possible, though
                  generally not desirable, to execute methods or constructors prior to
                  initialization. This can happen when a class hierarchy contains a
                  circularity in its static initialization, as in the following
                  example:
               </p><pre class="programlisting">
public class Foo {
    public static void main(String[] args) {
        Baz.testAsserts(); 
        // Will execute after Baz is initialized.
    }
}
class Bar {
    static {
        Baz.testAsserts(); 
        // Will execute before Baz is initialized!
    }
}
class Baz extends Bar {
    static void testAsserts() {
        boolean enabled = false;
        assert  enabled = true;
        System.out.println("Asserts " + 
			   (enabled ? "enabled" : "disabled"));
    }
}
</pre><p class="note">Invoking <code class="literal">Baz.testAsserts()</code>
                  causes <code class="literal">Baz</code> to be initialized. Before this can
                  happen, <code class="literal">Bar</code> must be
                  initialized. <code class="literal">Bar</code>'s static initializer again
                  invokes <code class="literal">Baz.testAsserts()</code>. Because initialization
                  of <code class="literal">Baz</code> is already in progress by the current
                  thread, the second invocation executes immediately,
                  though <code class="literal">Baz</code> is not initialized
                  (<a class="xref" href="jls-12.html#jls-12.4.2" title="12.4.2.&nbsp;Detailed Initialization Procedure">&sect;12.4.2</a>).
               </p>
               <p class="note">Because of the rule above, if the program above is
                  executed without enabling assertions, it must print:
               </p><pre class="screen">
Asserts enabled
Asserts disabled
</pre></div>
            <p class="norm-dynamic"><a name="jls-14.10-400"></a>A
               disabled <code class="literal">assert</code> statement does nothing. In particular, neither
               <span class="emphasis"><em>Expression1</em></span> nor <span class="emphasis"><em>Expression2</em></span>
               (if it is present) are evaluated. Execution of a disabled <code class="literal">assert</code>
               statement always completes normally.
            </p>
            <p class="norm-dynamic"><a name="jls-14.10-410"></a>An
               enabled <code class="literal">assert</code> statement is executed by first
               evaluating <span class="emphasis"><em>Expression1</em></span>. If the result is of type
               <code class="literal">Boolean</code>, it is subject to unboxing conversion
               (<a class="xref" href="jls-5.html#jls-5.1.8" title="5.1.8.&nbsp;Unboxing Conversion">&sect;5.1.8</a>).
            </p>
            <p class="norm-dynamic"><a name="jls-14.10-420"></a>If
               evaluation of <span class="emphasis"><em>Expression1</em></span> or the subsequent
               unboxing conversion (if any) completes abruptly for some reason, the
               <code class="literal">assert</code> statement completes abruptly for the same reason.
            </p>
            <p class="norm-dynamic"><a name="jls-14.10-430"></a>
               Otherwise, execution continues by making a choice based on the value
               of <span class="emphasis"><em>Expression1</em></span>:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.10-430-A"></a>If
                            the value is <code class="literal">true</code>, no further action is taken and the <code class="literal">assert</code>
                            statement completes normally.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.10-430-B"></a>If
                              the value is <code class="literal">false</code>, the execution behavior depends on
                              whether <span class="emphasis"><em>Expression2</em></span> is present:
                     </p>
                     <div class="norm">
                        <ul class="norm" type="circle">
                           <li class="listitem">
                              <p class="norm-dynamic"><a name="jls-14.10-430-B-A"></a>If <span class="emphasis"><em>Expression2</em></span>
                                           is present, it is evaluated. Then:
                              </p>
                              <div class="norm">
                                 <ul class="norm" type="square">
                                    <li class="listitem">
                                       <p class="norm-dynamic"><a name="jls-14.10-430-B-A-A"></a>If the evaluation completes
                                                        abruptly for some reason, the <code class="literal">assert</code> statement
                                                        completes abruptly for the same reason.
                                       </p>
                                    </li>
                                    <li class="listitem">
                                       <p class="norm-dynamic"><a name="jls-14.10-430-B-A-B"></a>If the evaluation
                                                        completes normally, an <code class="literal">AssertionError</code> instance whose
                                                        "detail message" is the resulting value
                                                        of <span class="emphasis"><em>Expression2</em></span> is
                                                        created. Then:
                                       </p>
                                       <div class="norm">
                                          <ul class="norm" type="disc">
                                             <li class="listitem">
                                                <p class="norm-dynamic"><a name="jls-14.10-430-B-A-B-A"></a>If the instance
                                                   	          creation completes abruptly for some reason, the
                                                   	          <code class="literal">assert</code> statement completes abruptly for the same
                                                   	          reason.
                                                </p>
                                             </li>
                                             <li class="listitem">
                                                <p class="norm-dynamic"><a name="jls-14.10-430-B-A-B-B"></a>If the instance
                                                   	          creation completes normally, the <code class="literal">assert</code> statement
                                                   	          completes abruptly by throwing the newly created
                                                   	          <code class="literal">AssertionError</code> object.
                                                </p>
                                             </li>
                                          </ul>
                                       </div>
                                    </li>
                                 </ul>
                              </div>
                           </li>
                           <li class="listitem">
                              <p class="norm-dynamic"><a name="jls-14.10-430-B-B"></a>If <span class="emphasis"><em>Expression2</em></span>
                                 	  is not present, an <code class="literal">AssertionError</code> instance with no "detail
                                 	  message" is created. Then:
                              </p>
                              <div class="norm">
                                 <ul class="norm" type="square">
                                    <li class="listitem">
                                       <p class="norm-dynamic"><a name="jls-14.10-430-B-B-A"></a>If the instance creation
                                          	      completes abruptly for some reason, the <code class="literal">assert</code>
                                          	      statement completes abruptly for the same reason.
                                       </p>
                                    </li>
                                    <li class="listitem">
                                       <p class="norm-dynamic"><a name="jls-14.10-430-B-B-B"></a>If the instance creation
                                          	      completes normally, the <code class="literal">assert</code> statement completes
                                          	      abruptly by throwing the newly created <code class="literal">AssertionError</code>
                                          	      object.
                                       </p>
                                    </li>
                                 </ul>
                              </div>
                           </li>
                        </ul>
                     </div>
                  </li>
               </ul>
            </div>
            <p class="note">Typically, assertion-checking is enabled during
               program development and testing, and disabled for deployment, to
               improve performance.
            </p>
            <p class="note">Because assertions may be disabled, programs must
               not assume that the expressions contained in assertions will be
               evaluated. Thus, these boolean expressions should generally be free of
               side effects. Evaluating such a boolean expression should not affect
               any state that is visible after the evaluation is complete. It is not
               illegal for a boolean expression contained in an assertion to have a
               side effect, but it is generally inappropriate, as it could cause
               program behavior to vary depending on whether assertions were enabled
               or disabled.
            </p>
            <p class="note">In light of this, assertions should not be used for
               argument checking in <code class="literal">public</code> methods. Argument checking is typically
               part of the contract of a method, and this contract must be upheld
               whether assertions are enabled or disabled.
            </p>
            <p class="note">A secondary problem with using assertions for
               argument checking is that erroneous arguments should result in an
               appropriate run-time exception (such as <code class="literal">IllegalArgumentException</code>,
               <code class="literal">ArrayIndexOutOfBoundsException</code>, or <code class="literal">NullPointerException</code>). An assertion failure will not throw an
               appropriate exception. Again, it is not illegal to use assertions for
               argument checking on <code class="literal">public</code> methods, but it is generally
               inappropriate. It is intended that <code class="literal">AssertionError</code> never be caught,
               but it is possible to do so, thus the rules for <code class="literal">try</code> statements
               should treat assertions appearing in a <code class="literal">try</code> block similarly to the
               current treatment of <code class="literal">throw</code> statements.
            </p>
         </div>
         <div class="section" title="14.11.&nbsp;The switch Statement">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-14.11"></a>14.11.&nbsp;The <code class="literal">switch</code> Statement
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm"><a name="jls-14.11-100"></a>The <code class="literal">switch</code> statement
               transfers control to one of several statements depending on the value
               of an expression.
            </p>
            <div id="jls-14.11-110" class="productionset"><a name="jls-14.11-110"></a>
                 
               <div class="production"><a name="jls-SwitchStatement"></a>
                      
                  <div class="lhs">SwitchStatement:</div>
                      
                  <div class="rhs">
                           <code class="literal">switch</code> <code class="literal">(</code> <a href="jls-15.html#jls-Expression" title="Expression">Expression</a> <code class="literal">)</code>
                           <a href="jls-14.html#jls-SwitchBlock" title="SwitchBlock">SwitchBlock</a>
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-SwitchBlock"></a>
                      
                  <div class="lhs">SwitchBlock:</div>
                      
                  <div class="rhs">
                           <code class="literal">{</code>
                           {<a href="jls-14.html#jls-SwitchBlockStatementGroup" title="SwitchBlockStatementGroup">SwitchBlockStatementGroup</a>}
                           {<a href="jls-14.html#jls-SwitchLabel" title="SwitchLabel">SwitchLabel</a>}
                           <code class="literal">}</code>
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-SwitchBlockStatementGroup"></a>
                      
                  <div class="lhs">SwitchBlockStatementGroup:</div>
                      
                  <div class="rhs">
                           <a href="jls-14.html#jls-SwitchLabels" title="SwitchLabels">SwitchLabels</a> <a href="jls-14.html#jls-BlockStatements" title="BlockStatements">BlockStatements</a>
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-SwitchLabels"></a>
                      
                  <div class="lhs">SwitchLabels:</div>
                      
                  <div class="rhs">
                           <a href="jls-14.html#jls-SwitchLabel" title="SwitchLabel">SwitchLabel</a> {<a href="jls-14.html#jls-SwitchLabel" title="SwitchLabel">SwitchLabel</a>}
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-SwitchLabel"></a>
                      
                  <div class="lhs">SwitchLabel:</div>
                      
                  <div class="rhs">
                           <code class="literal">case</code> <a href="jls-15.html#jls-ConstantExpression" title="ConstantExpression">ConstantExpression</a> <code class="literal">:</code> <br>
                           <code class="literal">case</code> <a href="jls-14.html#jls-EnumConstantName" title="EnumConstantName">EnumConstantName</a> <code class="literal">:</code> <br>
                           <code class="literal">default</code> <code class="literal">:</code>
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-EnumConstantName"></a>
                      
                  <div class="lhs">EnumConstantName:</div>
                      
                  <div class="rhs">
                           <a href="jls-3.html#jls-Identifier" title="Identifier">Identifier</a>
                         
                  </div>
                    
               </div>
               
            </div>
            <p class="norm-error"><a name="jls-14.11-200"></a>The type of the
               <span class="emphasis"><em>Expression</em></span> must be <code class="literal">char</code>, <code class="literal">byte</code>, <code class="literal">short</code>, <code class="literal">int</code>, <code class="literal">Character</code>,
               <code class="literal">Byte</code>, <code class="literal">Short</code>, <code class="literal">Integer</code>, <code class="literal">String</code>, or an enum
               type (<a class="xref" href="jls-8.html#jls-8.9" title="8.9.&nbsp;Enum Types">&sect;8.9</a>), or a compile-time error
               occurs.
            </p>
            <p class="norm-static"><a name="jls-14.11-300"></a>The body of
               a <code class="literal">switch</code> statement is known as a <span class="emphasis"><em>switch
                     block</em></span>. Any statement immediately contained by the switch
               block may be labeled with one or more <span class="emphasis"><em>switch
                     labels</em></span>, which are <code class="literal">case</code> or <code class="literal">default</code> labels. Every <code class="literal">case</code>
               label has a <code class="literal">case</code> constant, which is either a constant expression or
               the name of an enum constant. Switch labels and their <code class="literal">case</code> constants
               are said to be <span class="emphasis"><em>associated</em></span> with the <code class="literal">switch</code>
               statement.
            </p>
            <p class="norm-error"><a name="jls-14.11-310"></a>Given a
               <code class="literal">switch</code> statement, all of the following must be true or a
               compile-time error occurs:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-14.11-310-A"></a>
                              Every <code class="literal">case</code> constant associated with the <code class="literal">switch</code> statement
                              must be assignment compatible with the type of the <code class="literal">switch</code>
                              statement's <span class="emphasis"><em>Expression</em></span> (<a class="xref" href="jls-5.html#jls-5.2" title="5.2.&nbsp;Assignment Contexts">&sect;5.2</a>).
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-14.11-310-B"></a>
                              If the type of the <code class="literal">switch</code> statement's <span class="emphasis"><em>Expression</em></span> is an enum
                              type, then every <code class="literal">case</code> constant associated with the <code class="literal">switch</code>
                              statement must be an enum constant of that type.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-14.11-310-C"></a>
                              No two of the <code class="literal">case</code> constants associated with the <code class="literal">switch</code>
                              statement have the same value.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-14.11-310-D"></a>
                              No <code class="literal">case</code> constant associated with the <code class="literal">switch</code> statement is
                              <code class="literal">null</code>.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-14.11-310-E"></a>
                              At most one <code class="literal">default</code> label is associated with the <code class="literal">switch</code>
                              statement.
                     </p>
                  </li>
               </ul>
            </div>
            <p class="note">The prohibition against using <code class="literal">null</code> as a <code class="literal">case</code>
               constant prevents code being written that can never be executed. If
               the <code class="literal">switch</code> statement's <span class="emphasis"><em>Expression</em></span> is of a
               reference type, that is, <code class="literal">String</code> or a boxed primitive type or an enum
               type, then an exception will be thrown will occur if
               the <span class="emphasis"><em>Expression</em></span> evaluates to <code class="literal">null</code> at run
               time. In the judgment of the designers of the Java programming language, this is a
               better outcome than silently skipping the entire <code class="literal">switch</code> statement or
               choosing to execute the statements (if any) after the <code class="literal">default</code> label
               (if any).
            </p>
            <p class="note">A Java compiler is encouraged (but not required) to
               provide a warning if a <code class="literal">switch</code> on an enum-valued expression lacks a
               <code class="literal">default</code> label and lacks <code class="literal">case</code> labels for one or more of the enum's
               constants. Such a <code class="literal">switch</code> will silently do nothing if the expression
               evaluates to one of the missing constants.
            </p>
            <div class="informalexample">
               <p class="note">In C and C++ the body of a <code class="literal">switch</code> statement can be
                  a statement and statements with <code class="literal">case</code> labels do not have to be
                  immediately contained by that statement. Consider the simple
                  loop:
               </p><pre class="screen">
for (i = 0; i &lt; n; ++i) foo();
</pre><p class="note">where <code class="literal">n</code> is known to be
                  positive. A trick known as <span class="emphasis"><em>Duff's device</em></span> can be
                  used in C or C++ to unroll the loop, but this is not valid code in the
                  Java programming language:
               </p><pre class="screen">
int q = (n+7)/8;
switch (n%8) {
    case 0: do { foo();    // Great C hack, Tom,
    case 7:      foo();    // but it's not valid here.
    case 6:      foo();
    case 5:      foo();
    case 4:      foo();
    case 3:      foo();
    case 2:      foo();
    case 1:      foo();
            } while (--q &gt; 0);
}
</pre><p class="note">Fortunately, this trick does not seem to be widely
                  known or used. Moreover, it is less needed nowadays; this sort of code
                  transformation is properly in the province of state-of-the-art
                  optimizing compilers.
               </p>
            </div>
            <p class="norm-dynamic"><a name="jls-14.11-400"></a>
               When the <code class="literal">switch</code> statement is executed, first the <span class="emphasis"><em>Expression</em></span> is
               evaluated. If the <span class="emphasis"><em>Expression</em></span> evaluates to <code class="literal">null</code>, a <code class="literal">NullPointerException</code> is thrown
               and the entire <code class="literal">switch</code> statement completes abruptly for that
               reason. Otherwise, if the result is of a reference type, it is subject
               to unboxing conversion (<a class="xref" href="jls-5.html#jls-5.1.8" title="5.1.8.&nbsp;Unboxing Conversion">&sect;5.1.8</a>).
            </p>
            <p class="norm-dynamic"><a name="jls-14.11-410"></a>
               If evaluation of the <span class="emphasis"><em>Expression</em></span> or the subsequent unboxing
               conversion (if any) completes abruptly for some reason, the <code class="literal">switch</code>
               statement completes abruptly for the same reason.
            </p>
            <p class="norm-dynamic"><a name="jls-14.11-420"></a>
               Otherwise, execution continues by comparing the value of the
               <span class="emphasis"><em>Expression</em></span> with each <code class="literal">case</code> constant, and there is a choice:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.11-420-A"></a>
                              If one of the <code class="literal">case</code> constants is equal to the value of the
                              expression, then we say that the <code class="literal">case</code>
                              label <span class="emphasis"><em>matches</em></span>. All statements after the
                              matching <code class="literal">case</code> label in the <code class="literal">switch</code> block, if any, are
                              executed in sequence.
                     </p>
                     <p class="norm-dynamic"><a name="jls-14.11-420-A.1"></a>
                              If all these statements complete normally, or if there are no
                              statements after the matching <code class="literal">case</code> label, then the entire
                              <code class="literal">switch</code> statement completes normally.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.11-420-B"></a>
                              If no <code class="literal">case</code> label matches but there is a <code class="literal">default</code> label, then
                              all statements after the  <code class="literal">default</code> label in the
                              <code class="literal">switch</code> block, if any, are executed in sequence.
                     </p>
                     <p class="norm-dynamic"><a name="jls-14.11-420-B.1"></a>
                              If all these statements complete normally, or if there are no
                              statements after the <code class="literal">default</code> label, then the entire <code class="literal">switch</code>
                              statement completes normally.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.11-420-C"></a>
                              If no <code class="literal">case</code> label matches and there is no <code class="literal">default</code> label, then
                              no further action is taken and the <code class="literal">switch</code> statement completes
                              normally.
                     </p>
                  </li>
               </ul>
            </div>
            <p class="norm-dynamic"><a name="jls-14.11-430"></a>
               If any statement immediately contained by the <span class="emphasis"><em>Block</em></span> body of the
               <code class="literal">switch</code> statement completes abruptly, it is handled as
               follows:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.11-430-A"></a>
                              If execution of the <span class="emphasis"><em>Statement</em></span> completes abruptly because of a
                              <code class="literal">break</code> with no label, no further action is taken and the
                              <code class="literal">switch</code> statement completes normally.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.11-430-B"></a>
                              If execution of the <span class="emphasis"><em>Statement</em></span> completes abruptly for any other
                              reason, the <code class="literal">switch</code> statement completes abruptly for the same
                              reason.
                     </p>
                     <p class="note">The case of abrupt completion because of a
                              <code class="literal">break</code> with a label is handled by the general rule for labeled
                              statements (<a class="xref" href="jls-14.html#jls-14.7" title="14.7.&nbsp;Labeled Statements">&sect;14.7</a>).
                     </p>
                  </li>
               </ul>
            </div>
            <div class="example"><a name="d5e20563"></a><p class="title"><b>Example&nbsp;14.11-1.&nbsp;Fall-Through in the <code class="literal">switch</code> Statement</b></p>
               <div class="example-contents">
                  <p class="note">As in C and C++, execution of statements in a
                     <code class="literal">switch</code> block "falls through labels."
                  </p>
                  <p class="note">For example, the program:</p><pre class="programlisting">
class TooMany {
    static void howMany(int k) {
        switch (k) {
            case 1: System.out.print("one ");
            case 2: System.out.print("too ");
            case 3: System.out.println("many");
        }
    }
    public static void main(String[] args) {
        howMany(3);
        howMany(2);
        howMany(1);
    }
}
</pre><p class="note">contains a <code class="literal">switch</code> block in which the code for each
                     <code class="literal">case</code> falls through into the code for the next <code class="literal">case</code>. As a result,
                     the program prints:
                  </p><pre class="screen">
many
too many
one too many
</pre><p class="note">If code is not to fall through <code class="literal">case</code> to <code class="literal">case</code> in
                     this manner, then <code class="literal">break</code> statements should be used, as in this
                     example:
                  </p><pre class="programlisting">
class TwoMany {
    static void howMany(int k) {
        switch (k) {
            case 1: System.out.println("one");
                    break;  // exit the switch
            case 2: System.out.println("two");
                    break;  // exit the switch
            case 3: System.out.println("many");
                    break;  // not needed, but good style
        }
    }
    public static void main(String[] args) {
        howMany(1);
        howMany(2);
        howMany(3);
    }
}
</pre><p class="note">This program prints:</p><pre class="screen">
one
two
many
</pre></div>
            </div><br class="example-break"></div>
         <div class="section" title="14.12.&nbsp;The while Statement">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-14.12"></a>14.12.&nbsp;The <code class="literal">while</code> Statement
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm"><a name="jls-14.12-100"></a>The <code class="literal">while</code> statement
               executes an <span class="emphasis"><em>Expression</em></span> and a <span class="emphasis"><em>Statement</em></span> repeatedly until the value
               of the <span class="emphasis"><em>Expression</em></span> is <code class="literal">false</code>.
            </p>
            <div id="jls-14.12-110" class="productionset"><a name="jls-14.12-110"></a>
                 
               <div class="production"><a name="jls-WhileStatement"></a>
                      
                  <div class="lhs">WhileStatement:</div>
                      
                  <div class="rhs">
                           <code class="literal">while</code> <code class="literal">(</code> <a href="jls-15.html#jls-Expression" title="Expression">Expression</a> <code class="literal">)</code>
                           <a href="jls-14.html#jls-Statement" title="Statement">Statement</a>
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-WhileStatementNoShortIf"></a>
                      
                  <div class="lhs">WhileStatementNoShortIf:</div>
                      
                  <div class="rhs">
                           <code class="literal">while</code> <code class="literal">(</code> <a href="jls-15.html#jls-Expression" title="Expression">Expression</a> <code class="literal">)</code>
                           <a href="jls-14.html#jls-StatementNoShortIf" title="StatementNoShortIf">StatementNoShortIf</a>
                         
                  </div>
                    
               </div>
               
            </div>
            <p class="norm-error"><a name="jls-14.12-200"></a>The
               <span class="emphasis"><em>Expression</em></span> must have type <code class="literal">boolean</code> or <code class="literal">Boolean</code>, or a compile-time
               error occurs.
            </p>
            <p class="norm-dynamic"><a name="jls-14.12-300"></a>
               A <code class="literal">while</code> statement is executed by first evaluating the
               <span class="emphasis"><em>Expression</em></span>. If the result is of type <code class="literal">Boolean</code>, it is subject to
               unboxing conversion (<a class="xref" href="jls-5.html#jls-5.1.8" title="5.1.8.&nbsp;Unboxing Conversion">&sect;5.1.8</a>).
            </p>
            <p class="norm-dynamic"><a name="jls-14.12-310"></a>
               If evaluation of the <span class="emphasis"><em>Expression</em></span> or the subsequent unboxing
               conversion (if any) completes abruptly for some reason, the <code class="literal">while</code>
               statement completes abruptly for the same reason.
            </p>
            <p class="norm-dynamic"><a name="jls-14.12-320"></a>
               Otherwise, execution continues by making a choice based on the
               resulting value:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.12-320-A"></a>
                              If the value is <code class="literal">true</code>, then the contained <span class="emphasis"><em>Statement</em></span> is
                              executed. Then there is a choice:
                     </p>
                     <div class="norm">
                        <ul class="norm" type="circle">
                           <li class="listitem">
                              <p class="norm-dynamic"><a name="jls-14.12-320-A-A"></a>
                                 	  If execution of the <span class="emphasis"><em>Statement</em></span> completes normally, then the
                                 	  entire <code class="literal">while</code> statement is executed again, beginning by
                                 	  re-evaluating the <span class="emphasis"><em>Expression</em></span>.
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="norm-dynamic"><a name="jls-14.12-320-A-B"></a>
                                 	  If execution of the <span class="emphasis"><em>Statement</em></span> completes abruptly, see
                                 	  <a class="xref" href="jls-14.html#jls-14.12.1" title="14.12.1.&nbsp;Abrupt Completion of while Statement">&sect;14.12.1</a>.
                              </p>
                           </li>
                        </ul>
                     </div>
                  </li>
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.12-320-B"></a>
                              If the (possibly unboxed) value of the <span class="emphasis"><em>Expression</em></span> is <code class="literal">false</code>,
                              no further action is taken and the <code class="literal">while</code> statement completes
                              normally.
                     </p>
                     <p class="note">If the (possibly unboxed) value of the
                              <span class="emphasis"><em>Expression</em></span> is <code class="literal">false</code> the first time it is evaluated, then the
                              <span class="emphasis"><em>Statement</em></span> is not executed.
                     </p>
                  </li>
               </ul>
            </div>
            <div class="section" title="14.12.1.&nbsp;Abrupt Completion of while Statement">
               <div class="titlepage">
                  <div>
                     <div>
                        <h3 class="title"><a name="jls-14.12.1"></a>14.12.1.&nbsp;Abrupt Completion of <code class="literal">while</code> Statement
                        </h3>
                     </div>
                  </div>
               </div>
               <p class="norm-dynamic"><a name="jls-14.12.1-100"></a>
                  Abrupt completion of the contained <span class="emphasis"><em>Statement</em></span> is handled in the
                  following manner:
               </p>
               <div class="norm">
                  <ul class="norm" type="disc">
                     <li class="listitem">
                        <p class="norm-dynamic"><a name="jls-14.12.1-100-A"></a>
                                 If execution of the <span class="emphasis"><em>Statement</em></span> completes abruptly because of a
                                 <code class="literal">break</code> with no label, no further action is taken and the
                                 <code class="literal">while</code> statement completes normally.
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="norm-dynamic"><a name="jls-14.12.1-100-B"></a>
                                 If execution of the <span class="emphasis"><em>Statement</em></span> completes abruptly because of a
                                 <code class="literal">continue</code> with no label, then the entire <code class="literal">while</code> statement is
                                 executed again.
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="norm-dynamic"><a name="jls-14.12.1-100-C"></a>
                                 If execution of the <span class="emphasis"><em>Statement</em></span> completes abruptly because of a
                                 <code class="literal">continue</code> with label <code class="varname">L</code>, then there is a choice:
                        </p>
                        <div class="norm">
                           <ul class="norm" type="circle">
                              <li class="listitem">
                                 <p class="norm-dynamic"><a name="jls-14.12.1-100-C-A"></a>
                                    	  If the <code class="literal">while</code> statement has label <code class="varname">L</code>, then the entire
                                    	  <code class="literal">while</code> statement is executed again.
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-dynamic"><a name="jls-14.12.1-100-C-B"></a>
                                    	  If the <code class="literal">while</code> statement does not have label <code class="varname">L</code>, the
                                    	  <code class="literal">while</code> statement completes abruptly because of a <code class="literal">continue</code>
                                    	  with label <code class="varname">L</code>.
                                 </p>
                              </li>
                           </ul>
                        </div>
                     </li>
                     <li class="listitem">
                        <p class="norm-dynamic"><a name="jls-14.12.1-100-D"></a>
                                 If execution of the <span class="emphasis"><em>Statement</em></span> completes abruptly for any other
                                 reason, the <code class="literal">while</code> statement completes abruptly for the same
                                 reason.
                        </p>
                        <p class="note">The case of abrupt completion because of a
                                 <code class="literal">break</code> with a label is handled by the general rule for labeled
                                 statements (<a class="xref" href="jls-14.html#jls-14.7" title="14.7.&nbsp;Labeled Statements">&sect;14.7</a>).
                        </p>
                     </li>
                  </ul>
               </div>
            </div>
         </div>
         <div class="section" title="14.13.&nbsp;The do Statement">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-14.13"></a>14.13.&nbsp;The <code class="literal">do</code> Statement
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm"><a name="jls-14.13-100"></a>The <code class="literal">do</code> statement executes a
               <span class="emphasis"><em>Statement</em></span> and an <span class="emphasis"><em>Expression</em></span> repeatedly until the value of the
               <span class="emphasis"><em>Expression</em></span> is <code class="literal">false</code>.
            </p>
            <div id="jls-14.13-110" class="productionset"><a name="jls-14.13-110"></a>
                 
               <div class="production"><a name="jls-DoStatement"></a>
                      
                  <div class="lhs">DoStatement:</div>
                      
                  <div class="rhs">
                           <code class="literal">do</code> <a href="jls-14.html#jls-Statement" title="Statement">Statement</a> <code class="literal">while</code>
                           <code class="literal">(</code> <a href="jls-15.html#jls-Expression" title="Expression">Expression</a> <code class="literal">)</code> <code class="literal">;</code>
                         
                  </div>
                    
               </div>
               
            </div>
            <p class="norm-error"><a name="jls-14.13-200"></a>The
               <span class="emphasis"><em>Expression</em></span> must have type <code class="literal">boolean</code> or <code class="literal">Boolean</code>, or a compile-time
               error occurs.
            </p>
            <p class="norm-dynamic"><a name="jls-14.13-300"></a>
               A <code class="literal">do</code> statement is executed by first executing the <span class="emphasis"><em>Statement</em></span>. Then
               there is a choice:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.13-300-A"></a>
                              If execution of the <span class="emphasis"><em>Statement</em></span> completes normally, then the
                              <span class="emphasis"><em>Expression</em></span> is evaluated. If the result is of type <code class="literal">Boolean</code>,
                              it is subject to unboxing conversion
                              (<a class="xref" href="jls-5.html#jls-5.1.8" title="5.1.8.&nbsp;Unboxing Conversion">&sect;5.1.8</a>).
                     </p>
                     <p class="norm-dynamic"><a name="jls-14.13-300-A.1"></a>
                              If evaluation of the <span class="emphasis"><em>Expression</em></span> or the subsequent unboxing
                              conversion (if any) completes abruptly for some reason, the <code class="literal">do</code>
                              statement completes abruptly for the same reason.
                     </p>
                     <p class="norm-dynamic"><a name="jls-14.13-300-A.2"></a>
                              Otherwise, there is a choice based on the resulting value:
                     </p>
                     <div class="norm">
                        <ul class="norm" type="circle">
                           <li class="listitem">
                              <p class="norm-dynamic"><a name="jls-14.13-300-A.2-A"></a>
                                 	  If the value is <code class="literal">true</code>, then the entire <code class="literal">do</code> statement is
                                 	  executed again.
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="norm-dynamic"><a name="jls-14.13-300-A.2-B"></a>
                                 	  If the value is <code class="literal">false</code>, no further action is taken and the
                                 	  <code class="literal">do</code> statement completes normally.
                              </p>
                           </li>
                        </ul>
                     </div>
                  </li>
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.13-300-B"></a>
                              If execution of the <span class="emphasis"><em>Statement</em></span> completes abruptly, see
                              <a class="xref" href="jls-14.html#jls-14.13.1" title="14.13.1.&nbsp;Abrupt Completion of do Statement">&sect;14.13.1</a>.
                     </p>
                  </li>
               </ul>
            </div>
            <p class="note">Executing a <code class="literal">do</code> statement always executes the
               contained <span class="emphasis"><em>Statement</em></span> at least once.
            </p>
            <div class="section" title="14.13.1.&nbsp;Abrupt Completion of do Statement">
               <div class="titlepage">
                  <div>
                     <div>
                        <h3 class="title"><a name="jls-14.13.1"></a>14.13.1.&nbsp;Abrupt Completion of <code class="literal">do</code> Statement
                        </h3>
                     </div>
                  </div>
               </div>
               <p class="norm-dynamic"><a name="jls-14.13.1-100"></a>
                  Abrupt completion of the contained <span class="emphasis"><em>Statement</em></span> is handled in the
                  following manner:
               </p>
               <div class="norm">
                  <ul class="norm" type="disc">
                     <li class="listitem">
                        <p class="norm-dynamic"><a name="jls-14.13.1-100-A"></a>
                                 If execution of the <span class="emphasis"><em>Statement</em></span> completes abruptly because of a
                                 <code class="literal">break</code> with no label, then no further action is taken and the
                                 <code class="literal">do</code> statement completes normally.
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="norm-dynamic"><a name="jls-14.13.1-100-B"></a>
                                 If execution of the <span class="emphasis"><em>Statement</em></span> completes abruptly because of a
                                 <code class="literal">continue</code> with no label, then the <span class="emphasis"><em>Expression</em></span> is
                                 evaluated. Then there is a choice based on the resulting
                                 value:
                        </p>
                        <div class="norm">
                           <ul class="norm" type="circle">
                              <li class="listitem">
                                 <p class="norm-dynamic"><a name="jls-14.13.1-100-B-A"></a>
                                    	  If the value is <code class="literal">true</code>, then the entire <code class="literal">do</code> statement is
                                    	  executed again.
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-dynamic"><a name="jls-14.13.1-100-B-B"></a>
                                    	  If the value is <code class="literal">false</code>, no further action is taken and the
                                    	  <code class="literal">do</code> statement completes normally.
                                 </p>
                              </li>
                           </ul>
                        </div>
                     </li>
                     <li class="listitem">
                        <p class="norm-dynamic"><a name="jls-14.13.1-100-C"></a>
                                 If execution of the <span class="emphasis"><em>Statement</em></span> completes abruptly because of a
                                 <code class="literal">continue</code> with label <code class="varname">L</code>, then there is a choice:
                        </p>
                        <div class="norm">
                           <ul class="norm" type="circle">
                              <li class="listitem">
                                 <p class="norm-dynamic"><a name="jls-14.13.1-100-C-A"></a>
                                    	  If the <code class="literal">do</code> statement has label <code class="varname">L</code>, then the <span class="emphasis"><em>Expression</em></span>
                                    	  is evaluated. Then there is a choice:
                                 </p>
                                 <div class="norm">
                                    <ul class="norm" type="square">
                                       <li class="listitem">
                                          <p class="norm-dynamic"><a name="jls-14.13.1-100-C-A-A"></a>
                                             	      If the value of the <span class="emphasis"><em>Expression</em></span> is <code class="literal">true</code>, then the
                                             	      entire <code class="literal">do</code> statement is executed again.
                                          </p>
                                       </li>
                                       <li class="listitem">
                                          <p class="norm-dynamic"><a name="jls-14.13.1-100-C-A-B"></a>
                                             	      If the value of the <span class="emphasis"><em>Expression</em></span> is <code class="literal">false</code>, no further
                                             	      action is taken and the <code class="literal">do</code> statement completes
                                             	      normally.
                                          </p>
                                       </li>
                                    </ul>
                                 </div>
                              </li>
                              <li class="listitem">
                                 <p class="norm-dynamic"><a name="jls-14.13.1-100-C-B"></a>
                                    	  If the <code class="literal">do</code> statement does not have label <code class="varname">L</code>, the <code class="literal">do</code>
                                    	  statement completes abruptly because of a <code class="literal">continue</code> with
                                    	  label <code class="varname">L</code>.
                                 </p>
                              </li>
                           </ul>
                        </div>
                     </li>
                     <li class="listitem">
                        <p class="norm-dynamic"><a name="jls-14.13.1-100-D"></a>
                                 If execution of the <span class="emphasis"><em>Statement</em></span> completes abruptly for any other
                                 reason, the <code class="literal">do</code> statement completes abruptly for the same
                                 reason.
                        </p>
                        <p class="note">The case of abrupt completion because of a
                                 <code class="literal">break</code> with a label is handled by the general rule for labeled
                                 statements (<a class="xref" href="jls-14.html#jls-14.7" title="14.7.&nbsp;Labeled Statements">&sect;14.7</a>).
                        </p>
                     </li>
                  </ul>
               </div>
            </div>
            <div class="example"><a name="d5e20801"></a><p class="title"><b>Example&nbsp;14.13-1.&nbsp;The <code class="literal">do</code> Statement</b></p>
               <div class="example-contents">
                  <p class="note">The following code is one possible implementation of
                     the <code class="literal">toHexString</code> method of class <code class="literal">Integer</code>:
                  </p><pre class="programlisting">

public static String toHexString(int i) {
    StringBuffer buf = new StringBuffer(8);
    do {
        buf.append(Character.forDigit(i &amp; 0xF, 16));
        i &gt;&gt;&gt;= 4;
    } while (i != 0);
    return buf.reverse().toString();
}

</pre><p class="note">Because at least one digit must be generated, the
                     <code class="literal">do</code> statement is an appropriate control structure.
                  </p>
               </div>
            </div><br class="example-break"></div>
         <div class="section" title="14.14.&nbsp;The for Statement">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-14.14"></a>14.14.&nbsp;The <code class="literal">for</code> Statement
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm"><a name="jls-14.14-100"></a>The <code class="literal">for</code> statement has two
               forms:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.14-100-A"></a>
                              The basic <code class="literal">for</code> statement.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.14-100-B"></a>
                              The enhanced <code class="literal">for</code> statement
                     </p>
                  </li>
               </ul>
            </div>
            <div id="jls-14.14-110" class="productionset"><a name="jls-14.14-110"></a>
                 
               <div class="production"><a name="jls-ForStatement"></a>
                      
                  <div class="lhs">ForStatement:</div>
                      
                  <div class="rhs">
                           <a href="jls-14.html#jls-BasicForStatement" title="BasicForStatement">BasicForStatement</a> <br>
                           <a href="jls-14.html#jls-EnhancedForStatement" title="EnhancedForStatement">EnhancedForStatement</a>
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-ForStatementNoShortIf"></a>
                      
                  <div class="lhs">ForStatementNoShortIf:</div>
                      
                  <div class="rhs">
                           <a href="jls-14.html#jls-BasicForStatementNoShortIf" title="BasicForStatementNoShortIf">BasicForStatementNoShortIf</a> <br>
                           <a href="jls-14.html#jls-EnhancedForStatementNoShortIf" title="EnhancedForStatementNoShortIf">EnhancedForStatementNoShortIf</a>
                         
                  </div>
                    
               </div>
               
            </div>
            <div class="section" title="14.14.1.&nbsp;The basic for Statement">
               <div class="titlepage">
                  <div>
                     <div>
                        <h3 class="title"><a name="jls-14.14.1"></a>14.14.1.&nbsp;The basic <code class="literal">for</code> Statement
                        </h3>
                     </div>
                  </div>
               </div>
               <p class="norm"><a name="jls-14.14.1-100"></a>The basic <code class="literal">for</code> statement
                  executes some initialization code, then executes an <span class="emphasis"><em>Expression</em></span>, a
                  <span class="emphasis"><em>Statement</em></span>, and some update code repeatedly until the value of the
                  <span class="emphasis"><em>Expression</em></span> is <code class="literal">false</code>.
               </p>
               <div id="jls-14.14.1-110" class="productionset"><a name="jls-14.14.1-110"></a>
                    
                  <div class="production"><a name="jls-BasicForStatement"></a>
                         
                     <div class="lhs">BasicForStatement:</div>
                         
                     <div class="rhs">
                              <code class="literal">for</code> <code class="literal">(</code>
                              [<a href="jls-14.html#jls-ForInit" title="ForInit">ForInit</a>] <code class="literal">;</code>
                              [<a href="jls-15.html#jls-Expression" title="Expression">Expression</a>] <code class="literal">;</code>
                              [<a href="jls-14.html#jls-ForUpdate" title="ForUpdate">ForUpdate</a>]
                              <code class="literal">)</code> <a href="jls-14.html#jls-Statement" title="Statement">Statement</a>
                            
                     </div>
                       
                  </div>
                  
                    
                  <div class="production"><a name="jls-BasicForStatementNoShortIf"></a>
                         
                     <div class="lhs">BasicForStatementNoShortIf:</div>
                         
                     <div class="rhs">
                              <code class="literal">for</code> <code class="literal">(</code>
                              [<a href="jls-14.html#jls-ForInit" title="ForInit">ForInit</a>] <code class="literal">;</code>
                              [<a href="jls-15.html#jls-Expression" title="Expression">Expression</a>] <code class="literal">;</code>
                              [<a href="jls-14.html#jls-ForUpdate" title="ForUpdate">ForUpdate</a>]
                              <code class="literal">)</code> <a href="jls-14.html#jls-StatementNoShortIf" title="StatementNoShortIf">StatementNoShortIf</a>
                            
                     </div>
                       
                  </div>
                  
                    
                  <div class="production"><a name="jls-ForInit"></a>
                         
                     <div class="lhs">ForInit:</div>
                         
                     <div class="rhs">
                              <a href="jls-14.html#jls-StatementExpressionList" title="StatementExpressionList">StatementExpressionList</a> <br>
                              <a href="jls-14.html#jls-LocalVariableDeclaration" title="LocalVariableDeclaration">LocalVariableDeclaration</a>
                            
                     </div>
                       
                  </div>
                  
                    
                  <div class="production"><a name="jls-ForUpdate"></a>
                         
                     <div class="lhs">ForUpdate:</div>
                         
                     <div class="rhs"><a href="jls-14.html#jls-StatementExpressionList" title="StatementExpressionList">StatementExpressionList</a></div>
                       
                  </div>
                  
                    
                  <div class="production"><a name="jls-StatementExpressionList"></a>
                         
                     <div class="lhs">StatementExpressionList:</div>
                         
                     <div class="rhs">
                              <a href="jls-14.html#jls-StatementExpression" title="StatementExpression">StatementExpression</a> {<code class="literal">,</code> <a href="jls-14.html#jls-StatementExpression" title="StatementExpression">StatementExpression</a>}
                            
                     </div>
                       
                  </div>
                  
               </div>
               <p class="norm-error"><a name="jls-14.14.1-200"></a>The
                  <span class="emphasis"><em>Expression</em></span> must have type <code class="literal">boolean</code> or <code class="literal">Boolean</code>, or a compile-time
                  error occurs.
               </p>
               <p class="norm-static"><a name="jls-14.14.1-300"></a>The scope and shadowing of a local
                  variable declared in the <span class="emphasis"><em>ForInit</em></span> part of a basic
                  <code class="literal">for</code> statement is specified in <a class="xref" href="jls-6.html#jls-6.3" title="6.3.&nbsp;Scope of a Declaration">&sect;6.3</a> and
                  <a class="xref" href="jls-6.html#jls-6.4" title="6.4.&nbsp;Shadowing and Obscuring">&sect;6.4</a>.
               </p>
               <div class="section" title="14.14.1.1.&nbsp;Initialization of for Statement">
                  <div class="titlepage">
                     <div>
                        <div>
                           <h4 class="title"><a name="jls-14.14.1.1"></a>14.14.1.1.&nbsp;Initialization of <code class="literal">for</code> Statement
                           </h4>
                        </div>
                     </div>
                  </div>
                  <p class="norm-dynamic"><a name="jls-14.14.1.1-100"></a>
                     A <code class="literal">for</code> statement is executed by first executing
                     the <span class="emphasis"><em>ForInit</em></span> code:
                  </p>
                  <div class="norm">
                     <ul class="norm" type="disc">
                        <li class="listitem">
                           <p class="norm-dynamic"><a name="jls-14.14.1.1-100-A"></a>
                                    If the <span class="emphasis"><em>ForInit</em></span> code is a list of statement
                                    expressions (<a class="xref" href="jls-14.html#jls-14.8" title="14.8.&nbsp;Expression Statements">&sect;14.8</a>), the expressions are
                                    evaluated in sequence from left to right; their values, if any,
                                    are discarded.
                           </p>
                           <p class="norm-dynamic"><a name="jls-14.14.1.1-100-A.1"></a>
                                    If evaluation of any expression completes abruptly for some
                                    reason, the <code class="literal">for</code> statement completes abruptly for the same
                                    reason; any <span class="emphasis"><em>ForInit</em></span> statement expressions
                                    to the right of the one that completed abruptly are not
                                    evaluated.
                           </p>
                        </li>
                        <li class="listitem">
                           <p class="norm-dynamic"><a name="jls-14.14.1.1-100-B"></a>
                                    If the <span class="emphasis"><em>ForInit</em></span> code is a local variable
                                    declaration (<a class="xref" href="jls-14.html#jls-14.4" title="14.4.&nbsp;Local Variable Declaration Statements">&sect;14.4</a>), it is executed as if
                                    it were a local variable declaration statement appearing in a
                                    block.
                           </p>
                           <p class="norm-dynamic"><a name="jls-14.14.1.1-100-B.1"></a>
                                    If execution of the local variable declaration completes
                                    abruptly for any reason, the <code class="literal">for</code> statement completes abruptly
                                    for the same reason.
                           </p>
                        </li>
                        <li class="listitem">
                           <p class="norm-dynamic"><a name="jls-14.14.1.1-100-C"></a>
                                    If the <span class="emphasis"><em>ForInit</em></span> part is not present, no
                                    action is taken.
                           </p>
                        </li>
                     </ul>
                  </div>
               </div>
               <div class="section" title="14.14.1.2.&nbsp;Iteration of for Statement">
                  <div class="titlepage">
                     <div>
                        <div>
                           <h4 class="title"><a name="jls-14.14.1.2"></a>14.14.1.2.&nbsp;Iteration of <code class="literal">for</code> Statement
                           </h4>
                        </div>
                     </div>
                  </div>
                  <p class="norm-dynamic"><a name="jls-14.14.1.2-100"></a>
                     Next, a <code class="literal">for</code> iteration step is performed, as follows:
                  </p>
                  <div class="norm">
                     <ul class="norm" type="disc">
                        <li class="listitem">
                           <p class="norm-dynamic"><a name="jls-14.14.1.2-100-A"></a>
                                    If the <span class="emphasis"><em>Expression</em></span> is present, it is evaluated. If the result
                                    is of type <code class="literal">Boolean</code>, it is subject to unboxing conversion
                                    (<a class="xref" href="jls-5.html#jls-5.1.8" title="5.1.8.&nbsp;Unboxing Conversion">&sect;5.1.8</a>).
                           </p>
                           <p class="norm-dynamic"><a name="jls-14.14.1.2-100-A.1"></a>
                                    If evaluation of the <span class="emphasis"><em>Expression</em></span> or the subsequent unboxing
                                    conversion (if any) completes abruptly, the <code class="literal">for</code> statement
                                    completes abruptly for the same reason.
                           </p>
                           <p class="note">Otherwise, there is then a choice based on the
                                    presence or absence of the <span class="emphasis"><em>Expression</em></span> and the resulting value
                                    if the <span class="emphasis"><em>Expression</em></span> is present; see next bullet.
                           </p>
                        </li>
                        <li class="listitem">
                           <p class="norm-dynamic"><a name="jls-14.14.1.2-100-B"></a>
                                    If the <span class="emphasis"><em>Expression</em></span> is not present, or it is present and the
                                    value resulting from its evaluation (including any possible
                                    unboxing) is <code class="literal">true</code>, then the contained <span class="emphasis"><em>Statement</em></span> is
                                    executed. Then there is a choice:
                           </p>
                           <div class="norm">
                              <ul class="norm" type="circle">
                                 <li class="listitem">
                                    <p class="norm-dynamic"><a name="jls-14.14.1.2-100-B-A"></a>
                                       	  If execution of the <span class="emphasis"><em>Statement</em></span> completes normally, then the
                                       	  following two steps are performed in sequence:
                                    </p>
                                    <div class="orderedlist">
                                       <ol class="orderedlist" type="1">
                                          <li class="listitem">
                                             <p class="norm-dynamic"><a name="jls-14.14.1.2-100-B-A-A"></a>
                                                	      First, if the <span class="emphasis"><em>ForUpdate</em></span> part is
                                                	      present, the expressions are evaluated in sequence from
                                                	      left to right; their values, if any, are discarded. If
                                                	      evaluation of any expression completes abruptly for some
                                                	      reason, the <code class="literal">for</code> statement completes abruptly for the
                                                	      same reason; any <span class="emphasis"><em>ForUpdate</em></span>
                                                	      statement expressions to the right of the one that
                                                	      completed abruptly are not evaluated.
                                             </p>
                                             <p class="norm-dynamic"><a name="jls-14.14.1.2-100-B-A-A.1"></a>
                                                	      If the <span class="emphasis"><em>ForUpdate</em></span> part is not
                                                	      present, no action is taken.
                                             </p>
                                          </li>
                                          <li class="listitem">
                                             <p class="norm-dynamic"><a name="jls-14.14.1.2-100-B-A-B"></a>
                                                	      Second, another <code class="literal">for</code> iteration step is performed.
                                             </p>
                                          </li>
                                       </ol>
                                    </div>
                                 </li>
                                 <li class="listitem">
                                    <p class="norm-dynamic"><a name="jls-14.14.1.2-100-B-B"></a>
                                       	  If execution of the <span class="emphasis"><em>Statement</em></span> completes abruptly, see
                                       	  <a class="xref" href="jls-14.html#jls-14.14.1.3" title="14.14.1.3.&nbsp;Abrupt Completion of for Statement">&sect;14.14.1.3</a>.
                                    </p>
                                 </li>
                              </ul>
                           </div>
                        </li>
                        <li class="listitem">
                           <p class="norm-dynamic"><a name="jls-14.14.1.2-100-C"></a>
                                    If the <span class="emphasis"><em>Expression</em></span> is present and the value resulting from its
                                    evaluation (including any possible unboxing) is <code class="literal">false</code>, no
                                    further action is taken and the <code class="literal">for</code> statement completes
                                    normally.
                           </p>
                           <p class="note">If the (possibly unboxed) value of the
                                    <span class="emphasis"><em>Expression</em></span> is <code class="literal">false</code> the first time it is evaluated, then the
                                    <span class="emphasis"><em>Statement</em></span> is not executed.
                           </p>
                        </li>
                     </ul>
                  </div>
                  <p class="norm-dynamic"><a name="jls-14.14.1.2-200"></a>
                     If the <span class="emphasis"><em>Expression</em></span> is not present, then the only way a <code class="literal">for</code>
                     statement can complete normally is by use of a <code class="literal">break</code>
                     statement.
                  </p>
               </div>
               <div class="section" title="14.14.1.3.&nbsp;Abrupt Completion of for Statement">
                  <div class="titlepage">
                     <div>
                        <div>
                           <h4 class="title"><a name="jls-14.14.1.3"></a>14.14.1.3.&nbsp;Abrupt Completion of <code class="literal">for</code> Statement
                           </h4>
                        </div>
                     </div>
                  </div>
                  <p class="norm-dynamic"><a name="jls-14.14.1.3-100"></a>
                     Abrupt completion of the contained <span class="emphasis"><em>Statement</em></span> is handled in the
                     following manner:
                  </p>
                  <div class="norm">
                     <ul class="norm" type="disc">
                        <li class="listitem">
                           <p class="norm-dynamic"><a name="jls-14.14.1.3-100-A"></a>
                                    If execution of the <span class="emphasis"><em>Statement</em></span> completes abruptly because of a
                                    <code class="literal">break</code> with no label, no further action is taken and the <code class="literal">for</code>
                                    statement completes normally.
                           </p>
                        </li>
                        <li class="listitem">
                           <p class="norm-dynamic"><a name="jls-14.14.1.3-100-B"></a>
                                    If execution of the <span class="emphasis"><em>Statement</em></span> completes abruptly because of a
                                    <code class="literal">continue</code> with no label, then the following two steps are
                                    performed in sequence:
                           </p>
                           <div class="orderedlist">
                              <ol class="orderedlist" type="1">
                                 <li class="listitem">
                                    <p class="norm-dynamic"><a name="jls-14.14.1.3-100-B-A"></a>
                                       	  First, if the <span class="emphasis"><em>ForUpdate</em></span> part is
                                       	  present, the expressions are evaluated in sequence from left
                                       	  to right; their values, if any, are discarded.
                                    </p>
                                    <p class="norm-dynamic"><a name="jls-14.14.1.3-100-B-A.1"></a>
                                       	  If the <span class="emphasis"><em>ForUpdate</em></span> part is not present,
                                       	  no action is taken.
                                    </p>
                                 </li>
                                 <li class="listitem">
                                    <p class="norm-dynamic"><a name="jls-14.14.1.3-100-B-B"></a>
                                       	  Second, another <code class="literal">for</code> iteration step is performed.
                                    </p>
                                 </li>
                              </ol>
                           </div>
                        </li>
                        <li class="listitem">
                           <p class="norm-dynamic"><a name="jls-14.14.1.3-100-C"></a>
                                    If execution of the <span class="emphasis"><em>Statement</em></span> completes abruptly because of a
                                    <code class="literal">continue</code> with label <code class="varname">L</code>, then there is a choice:
                           </p>
                           <div class="norm">
                              <ul class="norm" type="circle">
                                 <li class="listitem">
                                    <p class="norm-dynamic"><a name="jls-14.14.1.3-100-C-A"></a>
                                       	  If the <code class="literal">for</code> statement has label <code class="varname">L</code>, then the following two
                                       	  steps are performed in sequence:
                                    </p>
                                    <div class="orderedlist">
                                       <ol class="orderedlist" type="1">
                                          <li class="listitem">
                                             <p class="norm-dynamic"><a name="jls-14.14.1.3-100-C-A-A"></a>
                                                	      First, if the <span class="emphasis"><em>ForUpdate</em></span> part is
                                                	      present, the expressions are evaluated in sequence from
                                                	      left to right; their values, if any, are
                                                	      discarded.
                                             </p>
                                             <p class="norm-dynamic"><a name="jls-14.14.1.3-100-C-A-A.1"></a>
                                                	      If the <span class="emphasis"><em>ForUpdate</em></span> is not present, no
                                                	      action is taken.
                                             </p>
                                          </li>
                                          <li class="listitem">
                                             <p class="norm-dynamic"><a name="jls-14.14.1.3-100-C-A-B"></a>
                                                	      Second, another <code class="literal">for</code> iteration step is performed.
                                             </p>
                                          </li>
                                       </ol>
                                    </div>
                                 </li>
                                 <li class="listitem">
                                    <p class="norm-dynamic"><a name="jls-14.14.1.3-100-C-B"></a>
                                       	  If the <code class="literal">for</code> statement does not have label <code class="varname">L</code>, the <code class="literal">for</code>
                                       	  statement completes abruptly because of a <code class="literal">continue</code> with
                                       	  label <code class="varname">L</code>.
                                    </p>
                                 </li>
                              </ul>
                           </div>
                        </li>
                        <li class="listitem">
                           <p class="norm-dynamic"><a name="jls-14.14.1.3-100-D"></a>
                                    If execution of the <span class="emphasis"><em>Statement</em></span> completes abruptly for any other
                                    reason, the <code class="literal">for</code> statement completes abruptly for the same
                                    reason.
                           </p>
                           <p class="note">Note that the case of abrupt completion because
                                    of a <code class="literal">break</code> with a label is handled by the general rule for
                                    labeled statements (<a class="xref" href="jls-14.html#jls-14.7" title="14.7.&nbsp;Labeled Statements">&sect;14.7</a>).
                           </p>
                        </li>
                     </ul>
                  </div>
               </div>
            </div>
            <div class="section" title="14.14.2.&nbsp;The enhanced for statement">
               <div class="titlepage">
                  <div>
                     <div>
                        <h3 class="title"><a name="jls-14.14.2"></a>14.14.2.&nbsp;The enhanced <code class="literal">for</code> statement
                        </h3>
                     </div>
                  </div>
               </div>
               <p class="norm-static"><a name="jls-14.14.2-100"></a>The
                  enhanced <code class="literal">for</code> statement has the form:
               </p>
               <div id="jls-14.14.2-110" class="productionset"><a name="jls-14.14.2-110"></a>
                    
                  <div class="production"><a name="jls-EnhancedForStatement"></a>
                         
                     <div class="lhs">EnhancedForStatement:</div>
                         
                     <div class="rhs">
                              <code class="literal">for</code> <code class="literal">(</code> 
                              {<a href="jls-8.html#jls-VariableModifier" title="VariableModifier">VariableModifier</a>}
                              <a href="jls-8.html#jls-UnannType" title="UnannType">UnannType</a> 
                              <a href="jls-8.html#jls-VariableDeclaratorId" title="VariableDeclaratorId">VariableDeclaratorId</a> 
                              
                              <code class="literal">:</code> <a href="jls-15.html#jls-Expression" title="Expression">Expression</a>
                              <code class="literal">)</code>
                              
                              <a href="jls-14.html#jls-Statement" title="Statement">Statement</a>
                            
                     </div>
                       
                  </div>
                  
                    
                  <div class="production"><a name="jls-EnhancedForStatementNoShortIf"></a>
                         
                     <div class="lhs">EnhancedForStatementNoShortIf:</div>
                         
                     <div class="rhs">
                              <code class="literal">for</code> <code class="literal">(</code> 
                              {<a href="jls-8.html#jls-VariableModifier" title="VariableModifier">VariableModifier</a>}
                              <a href="jls-8.html#jls-UnannType" title="UnannType">UnannType</a> 
                              <a href="jls-8.html#jls-VariableDeclaratorId" title="VariableDeclaratorId">VariableDeclaratorId</a>
                              
                              <code class="literal">:</code> <a href="jls-15.html#jls-Expression" title="Expression">Expression</a>
                              <code class="literal">)</code>
                              
                              <a href="jls-14.html#jls-StatementNoShortIf" title="StatementNoShortIf">StatementNoShortIf</a>
                            
                     </div>
                       
                  </div>
                  
               </div>
               <p class="note">See <a class="xref" href="jls-8.html#jls-8.3" title="8.3.&nbsp;Field Declarations">&sect;8.3</a> for 
                  <span class="emphasis"><em>UnannType</em></span>. The following productions from
                  <a class="xref" href="jls-4.html#jls-4.3" title="4.3.&nbsp;Reference Types and Values">&sect;4.3</a>, <a class="xref" href="jls-8.html#jls-8.4.1" title="8.4.1.&nbsp;Formal Parameters">&sect;8.4.1</a>, and
                  <a class="xref" href="jls-8.html#jls-8.3" title="8.3.&nbsp;Field Declarations">&sect;8.3</a> are shown here for convenience:
               </p>
               <div id="d5e21065" class="productionset"><a name="d5e21065"></a>
                    
                  <div class="productionrecap-note">
                     <div class="production">
                            
                        <div class="lhs">VariableModifier:</div>
                            
                        <div class="rhs">
                                 <a href="jls-9.html#jls-Annotation" title="Annotation">Annotation</a> <code class="literal">final</code>
                               
                        </div>
                          
                     </div>
                  </div>
                    
                  <div class="productionrecap-note">
                     <div class="production">
                            
                        <div class="lhs">VariableDeclaratorId:</div>
                            
                        <div class="rhs">
                                 <a href="jls-3.html#jls-Identifier" title="Identifier">Identifier</a> [<a href="jls-4.html#jls-Dims" title="Dims">Dims</a>]
                               
                        </div>
                          
                     </div>
                  </div>
                    
                  <div class="productionrecap-note">
                     <div class="production">
                            
                        <div class="lhs">Dims:</div>
                            
                        <div class="rhs">
                                 {<a href="jls-9.html#jls-Annotation" title="Annotation">Annotation</a>} <code class="literal">[</code> <code class="literal">]</code> {{<a href="jls-9.html#jls-Annotation" title="Annotation">Annotation</a>} <code class="literal">[</code> <code class="literal">]</code>}
                               
                        </div>
                          
                     </div>
                  </div>
                  
               </div>
               <p class="norm-error"><a name="jls-14.14.2-200"></a>The type
                  of the <span class="emphasis"><em>Expression</em></span> must be <code class="literal">Iterable</code> or an array type
                  (<a class="xref" href="jls-10.html#jls-10.1" title="10.1.&nbsp;Array Types">&sect;10.1</a>), or a compile-time error occurs.
               </p>
               <p class="norm-static"><a name="jls-14.14.2-210"></a>The scope and shadowing of the local
                  variable declared in the header of an enhanced <code class="literal">for</code> statement is
                  specified in <a class="xref" href="jls-6.html#jls-6.3" title="6.3.&nbsp;Scope of a Declaration">&sect;6.3</a> and
                  <a class="xref" href="jls-6.html#jls-6.4" title="6.4.&nbsp;Shadowing and Obscuring">&sect;6.4</a>.
               </p>
               <p class="norm-static"><a name="jls-14.14.2-300"></a>The
                  meaning of the enhanced <code class="literal">for</code> statement is given by translation into a
                  basic <code class="literal">for</code> statement, as follows:
               </p>
               <div class="norm">
                  <ul class="norm" type="disc">
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-14.14.2-300-A"></a>
                                 If the type of <span class="emphasis"><em>Expression</em></span> is a subtype of <code class="literal">Iterable</code>, then the
                                 translation is as follows.
                        </p>
                        <p class="norm-static"><a name="jls-14.14.2-300-A.1"></a>
                                 If the type of <span class="emphasis"><em>Expression</em></span> is a subtype of
                                 <code class="literal">Iterable</code><code class="literal">&lt;</code><span class="type">X</span><code class="literal">&gt;</code> for some type argument <span class="type">X</span>, then
                                 let <span class="type">I</span> be the type <code class="literal">java.util.Iterator</code><code class="literal">&lt;</code><span class="type">X</span><code class="literal">&gt;</code>; otherwise,
                                 let <span class="type">I</span> be the raw type <code class="literal">java.util.Iterator</code>.
                        </p>
                        <p class="norm-static"><a name="jls-14.14.2-300-A.2"></a>
                                 The enhanced <code class="literal">for</code> statement is equivalent to a basic <code class="literal">for</code>
                                 statement of the form:
                        </p><pre class="screen">
for (<span class="type">I</span> #i = <span class="emphasis"><em>Expression</em></span>.iterator(); #i.hasNext(); ) {
    <span class="emphasis"><em>{VariableModifier} TargetType Identifier</em></span> =
        (<span class="type">TargetType</span>) #i.next();
    <span class="emphasis"><em>Statement</em></span>
}
    </pre><p class="norm-static"><a name="jls-14.14.2-300-A.3"></a>
                                 <code class="literal">#i</code> is an automatically generated identifier
                                 that is distinct from any other identifiers (automatically
                                 generated or otherwise) that are in scope
                                 (<a class="xref" href="jls-6.html#jls-6.3" title="6.3.&nbsp;Scope of a Declaration">&sect;6.3</a>) at the point where the enhanced
                                 <code class="literal">for</code> statement occurs.
                        </p>
                        <p class="norm-static"><a name="jls-14.14.2-300-A.4"></a>
                                 If the <span class="emphasis"><em>UnannType</em></span> of the local variable in
                                 the header of the enhanced <code class="literal">for</code> statement is a reference type,
                                 then <span class="emphasis"><em>TargetType</em></span> is the 
                                 <span class="emphasis"><em>UnannType</em></span>; otherwise, 
                                 <span class="emphasis"><em>TargetType</em></span> is the upper bound of the
                                 capture conversion (<a class="xref" href="jls-5.html#jls-5.1.10" title="5.1.10.&nbsp;Capture Conversion">&sect;5.1.10</a>) of the type
                                 argument of <span class="type">I</span>, or <code class="literal">Object</code> if <span class="type">I</span> is raw.
                        </p>
                        <div class="informalexample">
                           <p class="note">For example, this code:</p><pre class="screen">
List&lt;? extends Integer&gt; l = ...
for (float i : l) ...
      </pre><p class="note">will be translated to:</p><pre class="screen">
for (Iterator&lt;Integer&gt; #i = l.iterator(); #i.hasNext(); ) {
    float #i0 = (Integer)#i.next();
    ...
      </pre></div>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-14.14.2-300-B"></a>
                                 Otherwise, the <span class="emphasis"><em>Expression</em></span> necessarily has an array type,
                                 <span class="type">T</span><code class="literal">[]</code>.
                        </p>
                        <p class="norm-static"><a name="jls-14.14.2-300-B.1"></a>
                                 Let <code class="varname">L<sub>1</sub></code> ... <code class="varname">L<sub>m</sub></code> be the (possibly empty) sequence of labels
                                 immediately preceding the enhanced <code class="literal">for</code> statement.
                        </p>
                        <p class="norm-static"><a name="jls-14.14.2-300-B.2"></a>
                                 The enhanced <code class="literal">for</code> statement is equivalent to a basic <code class="literal">for</code>
                                 statement of the form:
                        </p><pre class="screen">
<span class="type">T</span><code class="literal">[]</code> #a = <span class="emphasis"><em>Expression</em></span>;
<code class="varname">L<sub>1</sub></code>: <code class="varname">L<sub>2</sub></code>: ... <code class="varname">L<sub>m</sub></code>:
for (int #i = 0; #i &lt; #a.length; #i++) {
    <span class="emphasis"><em>{VariableModifier} TargetType Identifier</em></span> = #a[#i];
    <span class="emphasis"><em>Statement</em></span>
}
    </pre><p class="norm-static"><a name="jls-14.14.2-300-B.3"></a>
                                 <code class="literal">#a</code> and <code class="literal">#i</code> are
                                 automatically generated identifiers that are distinct from any
                                 other identifiers (automatically generated or otherwise) that
                                 are in scope at the point where the enhanced <code class="literal">for</code> statement
                                 occurs.
                        </p>
                        <p class="norm-static"><a name="jls-14.14.2-300-B.4"></a>
                                 <span class="emphasis"><em>TargetType</em></span> is the type of the local
                                 variable denoted by <span class="emphasis"><em>UnannType</em></span> in the header
                                 of the enhanced <code class="literal">for</code> statement, followed by any bracket pairs
                                 that follow the <span class="emphasis"><em>Identifier</em></span>
                                 (<a class="xref" href="jls-10.html#jls-10.2" title="10.2.&nbsp;Array Variables">&sect;10.2</a>).
                        </p>
                     </li>
                  </ul>
               </div>
               <div class="example"><a name="d5e21163"></a><p class="title"><b>Example&nbsp;14.14-1.&nbsp;Enhanced <code class="literal">for</code> And Arrays</b></p>
                  <div class="example-contents">
                     <p class="note">The following program, which calculates the sum of
                        an integer array, shows how enhanced <code class="literal">for</code> works for arrays:
                     </p><pre class="programlisting">

int sum(int[] a) {
    int sum = 0;
    for (int i : a) sum += i;
    return sum;
}

</pre></div>
               </div><br class="example-break"><div class="example"><a name="d5e21169"></a><p class="title"><b>Example&nbsp;14.14-2.&nbsp;Enhanced <code class="literal">for</code> And Unboxing Conversion</b></p>
                  <div class="example-contents">
                     <p class="note">The following program combines the enhanced <code class="literal">for</code>
                        statement with auto-unboxing to translate a histogram into a frequency
                        table:
                     </p><pre class="programlisting">

Map&lt;String, Integer&gt; histogram = ...;
double total = 0;
for (int i : histogram.values())
    total += i;
for (Map.Entry&lt;String, Integer&gt; e : histogram.entrySet())
    System.out.println(e.getKey() + " " + e.getValue() / total);
}

</pre></div>
               </div><br class="example-break"></div>
         </div>
         <div class="section" title="14.15.&nbsp;The break Statement">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-14.15"></a>14.15.&nbsp;The <code class="literal">break</code> Statement
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm"><a name="jls-14.15-100"></a>A <code class="literal">break</code> statement transfers
               control out of an enclosing statement.
            </p>
            <div id="jls-14.15-110" class="productionset"><a name="jls-14.15-110"></a>
                 
               <div class="production"><a name="jls-BreakStatement"></a>
                      
                  <div class="lhs">BreakStatement:</div>
                      
                  <div class="rhs">
                           <code class="literal">break</code> [<a href="jls-3.html#jls-Identifier" title="Identifier">Identifier</a>] <code class="literal">;</code>
                         
                  </div>
                    
               </div>
               
            </div>
            <p class="norm-dynamic"><a name="jls-14.15-200"></a>A <code class="literal">break</code>
               statement with no label attempts to transfer control to the innermost
               enclosing <code class="literal">switch</code>, <code class="literal">while</code>, <code class="literal">do</code>, or <code class="literal">for</code> statement of the
               immediately enclosing method or initializer; this statement, which is
               called the <span class="emphasis"><em>break target</em></span>, then immediately
               completes normally.
            </p>
            <p class="norm-dynamic"><a name="jls-14.15-210"></a>To be
               precise, a <code class="literal">break</code> statement with no label always completes abruptly,
               the reason being a <code class="literal">break</code> with no label.
            </p>
            <p class="norm-error"><a name="jls-14.15-220"></a>If no
               <code class="literal">switch</code>, <code class="literal">while</code>, <code class="literal">do</code>, or <code class="literal">for</code> statement in the immediately
               enclosing method, constructor, or initializer contains the <code class="literal">break</code>
               statement, a compile-time error occurs.
            </p>
            <p class="norm-dynamic"><a name="jls-14.15-300"></a>A <code class="literal">break</code>
               statement with label <span class="emphasis"><em>Identifier</em></span> attempts to transfer control to the
               enclosing labeled statement (<a class="xref" href="jls-14.html#jls-14.7" title="14.7.&nbsp;Labeled Statements">&sect;14.7</a>) that has the
               same <span class="emphasis"><em>Identifier</em></span> as its label; this statement, which is called
               the <span class="emphasis"><em>break target</em></span>, then immediately completes
               normally. In this case, the break target need not be a <code class="literal">switch</code>,
               <code class="literal">while</code>, <code class="literal">do</code>, or <code class="literal">for</code> statement.
            </p>
            <p class="norm-dynamic"><a name="jls-14.15-310"></a>To be
               precise, a <code class="literal">break</code> statement with label <span class="emphasis"><em>Identifier</em></span> always completes
               abruptly, the reason being a <code class="literal">break</code> with label <span class="emphasis"><em>Identifier</em></span>.
            </p>
            <p class="norm-error"><a name="jls-14.15-320"></a>A <code class="literal">break</code>
               statement must refer to a label within the immediately enclosing
               method, constructor, initializer, or lambda body. There are no
               non-local jumps. If no labeled statement with <span class="emphasis"><em>Identifier</em></span> as its
               label in the immediately enclosing method, constructor, initializer,
               or lambda body contains the <code class="literal">break</code> statement, a compile-time error
               occurs.
            </p>
            <p class="note">It can be seen, then, that a <code class="literal">break</code> statement
               always completes abruptly.
            </p>
            <p class="note">The preceding
               descriptions say "attempts to transfer control" rather than just
               "transfers control" because if there are any <code class="literal">try</code> statements
               (<a class="xref" href="jls-14.html#jls-14.20" title="14.20.&nbsp;The try statement">&sect;14.20</a>) within the break target whose <code class="literal">try</code>
               blocks or <code class="literal">catch</code> clauses contain the <code class="literal">break</code>
               statement, then any <code class="literal">finally</code> clauses of those <code class="literal">try</code> statements are
               executed, in order, innermost to outermost, before control is
               transferred to the break target. Abrupt completion of a <code class="literal">finally</code>
               clause can disrupt the transfer of control initiated by a <code class="literal">break</code>
               statement.
            </p>
            <div class="example"><a name="d5e21234"></a><p class="title"><b>Example&nbsp;14.15-1.&nbsp;The <code class="literal">break</code> Statement</b></p>
               <div class="example-contents">
                  <p class="note">In the following example, a mathematical graph is
                     represented by an array of arrays. A graph consists of a set of nodes
                     and a set of edges; each edge is an arrow that points from some node
                     to some other node, or from a node to itself. In this example it is
                     assumed that there are no redundant edges; that is, for any two
                     nodes <code class="varname">P</code> and <code class="varname">Q</code>,
                     where <code class="varname">Q</code> may be the same as <code class="varname">P</code>,
                     there is at most one edge from <code class="varname">P</code>
                     to <code class="varname">Q</code>.
                  </p>
                  <p class="note">Nodes are represented by integers, and there is an
                     edge from node <code class="varname">i</code> to node <code class="literal">edges[<code class="varname">i</code>][<code class="varname">j</code>]</code> for
                     every <code class="varname">i</code> and <code class="varname">j</code> for which the array
                     reference <code class="literal">edges[<code class="varname">i</code>][<code class="varname">j</code>]</code> does not throw an
                     <code class="literal">ArrayIndexOutOfBoundsException</code>.
                  </p>
                  <p class="note">The task of the method <code class="literal">loseEdges</code>,
                     given integers <code class="varname">i</code> and <code class="varname">j</code>, is to construct a new graph by copying a
                     given graph but omitting the edge from node <code class="varname">i</code> to node <code class="varname">j</code>, if any,
                     and the edge from node <code class="varname">j</code> to node <code class="varname">i</code>, if any:
                  </p><pre class="programlisting">
class Graph {
    int edges[][];
    public Graph(int[][] edges) { this.edges = edges; }

    public Graph loseEdges(int i, int j) {
        int n = edges.length;
        int[][] newedges = new int[n][];
        for (int k = 0; k &lt; n; ++k) {
edgelist:
{
            int z;
search:
{
            if (k == i) {
                for (z = 0; z &lt; edges[k].length; ++z) {
                    if (edges[k][z] == j) break search;
                }
            } else if (k == j) {
                for (z = 0; z &lt; edges[k].length; ++z) {
                    if (edges[k][z] == i) break search;
                }
            }

            // No edge to be deleted; share this list.
            newedges[k] = edges[k];
            break edgelist;
} //search

            // Copy the list, omitting the edge at position z.
            int m = edges[k].length - 1;
            int ne[] = new int[m];
            System.arraycopy(edges[k], 0, ne, 0, z);
            System.arraycopy(edges[k], z+1, ne, z, m-z);
            newedges[k] = ne;
} //edgelist
        }
        return new Graph(newedges);
    }
}
</pre><p class="note">Note the use of two statement
                     labels, <code class="literal">edgelist</code> and <code class="literal">search</code>, and
                     the use of <code class="literal">break</code> statements. This allows the code that copies a
                     list, omitting one edge, to be shared between two separate tests, the
                     test for an edge from node <code class="varname">i</code> to node <code class="varname">j</code>, and the test for an edge
                     from node <code class="varname">j</code> to node <code class="varname">i</code>.
                  </p>
               </div>
            </div><br class="example-break"></div>
         <div class="section" title="14.16.&nbsp;The continue Statement">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-14.16"></a>14.16.&nbsp;The <code class="literal">continue</code> Statement
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm"><a name="jls-14.16-100"></a>A <code class="literal">continue</code> statement may
               occur only in a <code class="literal">while</code>, <code class="literal">do</code>, or <code class="literal">for</code> statement; statements of these
               three kinds are called <span class="emphasis"><em>iteration
                     statements</em></span>. Control passes to the loop-continuation point
               of an iteration statement.
            </p>
            <div id="jls-14.16-110" class="productionset"><a name="jls-14.16-110"></a>
                 
               <div class="production"><a name="jls-ContinueStatement"></a>
                      
                  <div class="lhs">ContinueStatement:</div>
                      
                  <div class="rhs">
                           <code class="literal">continue</code> [<a href="jls-3.html#jls-Identifier" title="Identifier">Identifier</a>] <code class="literal">;</code>
                         
                  </div>
                    
               </div>
               
            </div>
            <p class="norm-dynamic"><a name="jls-14.16-200"></a>A
               <code class="literal">continue</code> statement with no label attempts to transfer control to the
               innermost enclosing <code class="literal">while</code>, <code class="literal">do</code>, or <code class="literal">for</code> statement of the
               immediately enclosing method, constructor, or initializer; this
               statement, which is called the <span class="emphasis"><em>continue target</em></span>,
               then immediately ends the current iteration and begins a new
               one.
            </p>
            <p class="norm-dynamic"><a name="jls-14.16-210"></a>To be
               precise, such a <code class="literal">continue</code> statement always completes abruptly, the
               reason being a <code class="literal">continue</code> with no label.
            </p>
            <p class="norm-error"><a name="jls-14.16-220"></a>If no
               <code class="literal">while</code>, <code class="literal">do</code>, or <code class="literal">for</code> statement of the immediately enclosing method,
               constructor, or initializer contains the <code class="literal">continue</code> statement, a
               compile-time error occurs.
            </p>
            <p class="norm-dynamic"><a name="jls-14.16-300"></a>A
               <code class="literal">continue</code> statement with label <span class="emphasis"><em>Identifier</em></span> attempts to transfer
               control to the enclosing labeled statement
               (<a class="xref" href="jls-14.html#jls-14.7" title="14.7.&nbsp;Labeled Statements">&sect;14.7</a>) that has the same <span class="emphasis"><em>Identifier</em></span> as its
               label; that statement, which is called the <span class="emphasis"><em>continue
                     target</em></span>, then immediately ends the current iteration and
               begins a new one.
            </p>
            <p class="norm-dynamic"><a name="jls-14.16-310"></a>To be
               precise, a <code class="literal">continue</code> statement with label <span class="emphasis"><em>Identifier</em></span> always
               completes abruptly, the reason being a <code class="literal">continue</code> with label
               <span class="emphasis"><em>Identifier</em></span>.
            </p>
            <p class="norm-error"><a name="jls-14.16-320"></a>The
               continue target must be a <code class="literal">while</code>, <code class="literal">do</code>, or <code class="literal">for</code> statement, or a
               compile-time error occurs.
            </p>
            <p class="norm-error"><a name="jls-14.16-330"></a>A <code class="literal">continue</code>
               statement must refer to a label within the immediately enclosing
               method, constructor, initializer, or lambda body. There are no
               non-local jumps. If no labeled statement with <span class="emphasis"><em>Identifier</em></span> as its
               label in the immediately enclosing method, constructor, initializer,
               or lambda body contains the <code class="literal">continue</code> statement, a compile-time error
               occurs.
            </p>
            <p class="note">It can be seen, then, that a <code class="literal">continue</code> statement
               always completes abruptly.
            </p>
            <p class="note">See the descriptions of the <code class="literal">while</code> statement
               (<a class="xref" href="jls-14.html#jls-14.12" title="14.12.&nbsp;The while Statement">&sect;14.12</a>), <code class="literal">do</code> statement
               (<a class="xref" href="jls-14.html#jls-14.13" title="14.13.&nbsp;The do Statement">&sect;14.13</a>), and <code class="literal">for</code> statement
               (<a class="xref" href="jls-14.html#jls-14.14" title="14.14.&nbsp;The for Statement">&sect;14.14</a>) for a discussion of the handling of
               abrupt termination because of <code class="literal">continue</code>.
            </p>
            <p class="note">The preceding
               descriptions say "attempts to transfer control" rather than just
               "transfers control" because if there are any <code class="literal">try</code> statements
               (<a class="xref" href="jls-14.html#jls-14.20" title="14.20.&nbsp;The try statement">&sect;14.20</a>) within the continue target whose <code class="literal">try</code>
               blocks or <code class="literal">catch</code> clauses contain the <code class="literal">continue</code>
               statement, then any <code class="literal">finally</code> clauses of those <code class="literal">try</code> statements are
               executed, in order, innermost to outermost, before control is
               transferred to the continue target. Abrupt completion of a <code class="literal">finally</code>
               clause can disrupt the transfer of control initiated by a <code class="literal">continue</code>
               statement.
            </p>
            <div class="example"><a name="d5e21341"></a><p class="title"><b>Example&nbsp;14.16-1.&nbsp;The <code class="literal">continue</code> Statement</b></p>
               <div class="example-contents">
                  <p class="note">In the <code class="literal">Graph</code> class in
                     <a class="xref" href="jls-14.html#jls-14.15" title="14.15.&nbsp;The break Statement">&sect;14.15</a>, one of the <code class="literal">break</code> statements is used to
                     finish execution of the entire body of the outermost <code class="literal">for</code> loop. This
                     break can be replaced by a <code class="literal">continue</code> if the <code class="literal">for</code> loop itself is
                     labeled:
                  </p><pre class="programlisting">
class Graph {
    int edges[][];
    public Graph(int[][] edges) { this.edges = edges; }

    public Graph loseEdges(int i, int j) {
        int n = edges.length;
        int[][] newedges = new int[n][];
edgelists:
        for (int k = 0; k &lt; n; ++k) {
            int z;
search:
{
            if (k == i) {
                for (z = 0; z &lt; edges[k].length; ++z) {
                    if (edges[k][z] == j) break search;
                }
            } else if (k == j) {
                for (z = 0; z &lt; edges[k].length; ++z) {
                    if (edges[k][z] == i) break search;
                }
            }

            // No edge to be deleted; share this list.
            newedges[k] = edges[k];
            continue edgelists;
} //search

            // Copy the list, omitting the edge at position z.
            int m = edges[k].length - 1;
            int ne[] = new int[m];
            System.arraycopy(edges[k], 0, ne, 0, z);
            System.arraycopy(edges[k], z+1, ne, z, m-z);
            newedges[k] = ne;
        } //edgelists
        return new Graph(newedges);
    }
}
</pre><p class="note">Which to use, if either, is largely a matter of
                     programming style.
                  </p>
               </div>
            </div><br class="example-break"></div>
         <div class="section" title="14.17.&nbsp;The return Statement">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-14.17"></a>14.17.&nbsp;The <code class="literal">return</code> Statement
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm"><a name="jls-14.17-100"></a>A <code class="literal">return</code> statement returns
               control to the invoker of a method (<a class="xref" href="jls-8.html#jls-8.4" title="8.4.&nbsp;Method Declarations">&sect;8.4</a>,
               <a class="xref" href="jls-15.html#jls-15.12" title="15.12.&nbsp;Method Invocation Expressions">&sect;15.12</a>) or constructor
               (<a class="xref" href="jls-8.html#jls-8.8" title="8.8.&nbsp;Constructor Declarations">&sect;8.8</a>, <a class="xref" href="jls-15.html#jls-15.9" title="15.9.&nbsp;Class Instance Creation Expressions">&sect;15.9</a>).
            </p>
            <div id="jls-14.17-110" class="productionset"><a name="jls-14.17-110"></a>
                 
               <div class="production"><a name="jls-ReturnStatement"></a>
                      
                  <div class="lhs">ReturnStatement:</div>
                      
                  <div class="rhs">
                           <code class="literal">return</code> [<a href="jls-15.html#jls-Expression" title="Expression">Expression</a>] <code class="literal">;</code>
                         
                  </div>
                    
               </div>
               
            </div>
            <p class="norm-static"><a name="jls-14.17-120"></a>A <code class="literal">return</code>
               statement is <span class="emphasis"><em>contained</em></span> in the innermost
               constructor, method, initializer, or lambda expression whose body
               encloses the <code class="literal">return</code> statement.
            </p>
            <p class="norm-error"><a name="jls-14.17-200"></a>It is a
               compile-time error if a <code class="literal">return</code> statement is contained in an instance
               initializer or a static initializer (<a class="xref" href="jls-8.html#jls-8.6" title="8.6.&nbsp;Instance Initializers">&sect;8.6</a>,
               <a class="xref" href="jls-8.html#jls-8.7" title="8.7.&nbsp;Static Initializers">&sect;8.7</a>).
            </p>
            <p class="norm-error"><a name="jls-14.17-300"></a>A <code class="literal">return</code>
               statement with no <span class="emphasis"><em>Expression</em></span> must be contained in one of the
               following, or a compile-time error occurs:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm-error"><a name="jls-14.17-300-A"></a>A
                              method that is declared, using the keyword <code class="literal">void</code>, not to return
                              a value (<a class="xref" href="jls-8.html#jls-8.4.5" title="8.4.5.&nbsp;Method Result">&sect;8.4.5</a>)
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-error"><a name="jls-14.17-300-B"></a>A
                              constructor (<a class="xref" href="jls-8.html#jls-8.8.7" title="8.8.7.&nbsp;Constructor Body">&sect;8.8.7</a>)
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-error"><a name="jls-14.17-300-C"></a>A lambda
                              expression (<a class="xref" href="jls-15.html#jls-15.27" title="15.27.&nbsp;Lambda Expressions">&sect;15.27</a>)
                     </p>
                  </li>
               </ul>
            </div>
            <p class="norm-dynamic"><a name="jls-14.17-310"></a>A <code class="literal">return</code>
               statement with no <span class="emphasis"><em>Expression</em></span> attempts to transfer control to the
               invoker of the method, constructor, or lambda body that contains
               it. To be precise, a <code class="literal">return</code> statement with no <span class="emphasis"><em>Expression</em></span> always
               completes abruptly, the reason being a return with no value.
            </p>
            <p class="norm-error"><a name="jls-14.17-400"></a>A <code class="literal">return</code>
               statement with an <span class="emphasis"><em>Expression</em></span> must be contained in one of the
               following, or a compile-time error occurs:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm-error"><a name="jls-14.17-400-A"></a>A
                              method that is declared to return a value
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-error"><a name="jls-14.17-400-B"></a>A lambda
                              expression
                     </p>
                  </li>
               </ul>
            </div>
            <p class="norm-error"><a name="jls-14.17-410"></a>The
               <span class="emphasis"><em>Expression</em></span> must denote a variable or a value, or a compile-time
               error occurs.
            </p>
            <p class="norm-error"><a name="jls-14.17-420"></a>When a <code class="literal">return</code>
               statement with an <span class="emphasis"><em>Expression</em></span> appears in a method declaration, the
               <span class="emphasis"><em>Expression</em></span> must be assignable (<a class="xref" href="jls-5.html#jls-5.2" title="5.2.&nbsp;Assignment Contexts">&sect;5.2</a>) to the
               declared return type of the method, or a compile-time error
               occurs.
            </p>
            <p class="norm-dynamic"><a name="jls-14.17-430"></a>A <code class="literal">return</code>
               statement with an <span class="emphasis"><em>Expression</em></span> attempts to transfer control to the
               invoker of the method or lambda body that contains it; the value of
               the <span class="emphasis"><em>Expression</em></span> becomes the value of the method invocation. More
               precisely, execution of such a <code class="literal">return</code> statement first evaluates the
               <span class="emphasis"><em>Expression</em></span>. If the evaluation of the <span class="emphasis"><em>Expression</em></span> completes abruptly
               for some reason, then the <code class="literal">return</code> statement completes abruptly for
               that reason. If evaluation of the <span class="emphasis"><em>Expression</em></span> completes normally,
               producing a value <code class="varname">V</code>, then the <code class="literal">return</code> statement
               completes abruptly, the reason being a return with
               value <code class="varname">V</code>.
            </p>
            <p class="norm-dynamic"><a name="jls-14.17-440"></a>If the
               expression is of type <code class="literal">float</code> and is not FP-strict
               (<a class="xref" href="jls-15.html#jls-15.4" title="15.4.&nbsp;FP-strict Expressions">&sect;15.4</a>), then the value may be an element of
               either the float value set or the float-extended-exponent value set
               (<a class="xref" href="jls-4.html#jls-4.2.3" title="4.2.3.&nbsp;Floating-Point Types, Formats, and Values">&sect;4.2.3</a>). If the expression is of type <code class="literal">double</code>
               and is not FP-strict, then the value may be an element of either the
               double value set or the double-extended-exponent value set.
            </p>
            <p class="note">It can be seen, then, that a <code class="literal">return</code> statement
               always completes abruptly.
            </p>
            <p class="note">The preceding
               descriptions say "attempts to transfer control" rather than just
               "transfers control" because if there are any <code class="literal">try</code> statements
               (<a class="xref" href="jls-14.html#jls-14.20" title="14.20.&nbsp;The try statement">&sect;14.20</a>) within the method or constructor whose
               <code class="literal">try</code> blocks or <code class="literal">catch</code> clauses contain the
               <code class="literal">return</code> statement, then any <code class="literal">finally</code> clauses of those <code class="literal">try</code>
               statements will be executed, in order, innermost to outermost, before
               control is transferred to the invoker of the method or
               constructor. Abrupt completion of a <code class="literal">finally</code> clause can disrupt the
               transfer of control initiated by a <code class="literal">return</code> statement.
            </p>
         </div>
         <div class="section" title="14.18.&nbsp;The throw Statement">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-14.18"></a>14.18.&nbsp;The <code class="literal">throw</code> Statement
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm"><a name="jls-14.18-100"></a>A <code class="literal">throw</code> statement causes an
               exception (<a class="xref" href="jls-11.html" title="Chapter&nbsp;11.&nbsp;Exceptions">&sect;11 (<i>Exceptions</i>)</a>) to be thrown. The result is an
               immediate transfer of control (<a class="xref" href="jls-11.html#jls-11.3" title="11.3.&nbsp;Run-Time Handling of an Exception">&sect;11.3</a>) that may
               exit multiple statements and multiple constructor, instance
               initializer, static initializer and field initializer evaluations, and
               method invocations until a <code class="literal">try</code> statement
               (<a class="xref" href="jls-14.html#jls-14.20" title="14.20.&nbsp;The try statement">&sect;14.20</a>) is found that catches the thrown
               value. If no such <code class="literal">try</code> statement is found, then execution of the
               thread (<a class="xref" href="jls-17.html" title="Chapter&nbsp;17.&nbsp;Threads and Locks">&sect;17 (<i>Threads and Locks</i>)</a>) that executed the <code class="literal">throw</code> is
               terminated (<a class="xref" href="jls-11.html#jls-11.3" title="11.3.&nbsp;Run-Time Handling of an Exception">&sect;11.3</a>) after invocation of
               the <code class="literal">uncaughtException</code> method for the thread group
               to which the thread belongs.
            </p>
            <div id="jls-14.18-110" class="productionset"><a name="jls-14.18-110"></a>
                 
               <div class="production"><a name="jls-ThrowStatement"></a>
                      
                  <div class="lhs">ThrowStatement:</div>
                      
                  <div class="rhs">
                           <code class="literal">throw</code> <a href="jls-15.html#jls-Expression" title="Expression">Expression</a> <code class="literal">;</code>
                         
                  </div>
                    
               </div>
               
            </div>
            <p class="norm-error"><a name="jls-14.18-200"></a>The
               <span class="emphasis"><em>Expression</em></span> in a <code class="literal">throw</code> statement must either denote a variable or
               value of a reference type which is assignable
               (<a class="xref" href="jls-5.html#jls-5.2" title="5.2.&nbsp;Assignment Contexts">&sect;5.2</a>) to the type <code class="literal">Throwable</code>, or denote the
               null reference, or a compile-time error occurs.
            </p>
            <p class="note">The reference type of the <span class="emphasis"><em>Expression</em></span> will always
               be a class type (since no interface types are assignable to
               <code class="literal">Throwable</code>) which is not parameterized (since a subclass of
               <code class="literal">Throwable</code> cannot be generic (<a class="xref" href="jls-8.html#jls-8.1.2" title="8.1.2.&nbsp;Generic Classes and Type Parameters">&sect;8.1.2</a>)).
            </p>
            <p class="norm-error"><a name="jls-14.18-210"></a>At least
               one of the following three conditions must be true, or a compile-time
               error occurs:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-14.18-210-A"></a>
                              The type of the <span class="emphasis"><em>Expression</em></span> is an unchecked exception class
                              (<a class="xref" href="jls-11.html#jls-11.1.1" title="11.1.1.&nbsp;The Kinds of Exceptions">&sect;11.1.1</a>)  or the null type
                              (<a class="xref" href="jls-4.html#jls-4.1" title="4.1.&nbsp;The Kinds of Types and Values">&sect;4.1</a>).
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-14.18-210-B"></a>
                              The <code class="literal">throw</code> statement is contained in the <code class="literal">try</code> block of a <code class="literal">try</code>
                              statement (<a class="xref" href="jls-14.html#jls-14.20" title="14.20.&nbsp;The try statement">&sect;14.20</a>) and   it is not the case that the
                              <code class="literal">try</code> statement can throw an exception of the type of the
                              <span class="emphasis"><em>Expression</em></span>.  (In this case we say the thrown value
                              is <span class="emphasis"><em>caught</em></span> by the <code class="literal">try</code> statement.)
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-14.18-210-C"></a>
                              The <code class="literal">throw</code> statement is contained in a method or constructor
                              declaration and the type of the <span class="emphasis"><em>Expression</em></span> is assignable
                              (<a class="xref" href="jls-5.html#jls-5.2" title="5.2.&nbsp;Assignment Contexts">&sect;5.2</a>) to at least one type listed in the
                              <code class="literal">throws</code> clause (<a class="xref" href="jls-8.html#jls-8.4.6" title="8.4.6.&nbsp;Method Throws">&sect;8.4.6</a>,
                              <a class="xref" href="jls-8.html#jls-8.8.5" title="8.8.5.&nbsp;Constructor Throws">&sect;8.8.5</a>) of the declaration.
                     </p>
                  </li>
               </ul>
            </div>
            <p class="norm-static"><a name="jls-14.18-300"></a>The
               exception types that a <code class="literal">throw</code> statement can throw are specified in
               <a class="xref" href="jls-11.html#jls-11.2.2" title="11.2.2.&nbsp;Exception Analysis of Statements">&sect;11.2.2</a>.
            </p>
            <p class="norm-dynamic"><a name="jls-14.18-400"></a>
               A <code class="literal">throw</code> statement first evaluates the <span class="emphasis"><em>Expression</em></span>. Then:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.18-400-A"></a>
                              If evaluation of the <span class="emphasis"><em>Expression</em></span> completes abruptly for some
                              reason, then the <code class="literal">throw</code> completes abruptly for that
                              reason.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.18-400-B"></a>
                              If evaluation of the <span class="emphasis"><em>Expression</em></span> completes normally, producing
                              a non-<code class="literal">null</code> value <code class="varname">V</code>, then the <code class="literal">throw</code>
                              statement completes abruptly, the reason being a <code class="literal">throw</code> with
                              value <code class="varname">V</code>.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-error"><a name="jls-14.18-400-C"></a>
                              If evaluation of the <span class="emphasis"><em>Expression</em></span> completes normally, producing
                              a <code class="literal">null</code> value, then an instance <code class="varname">V'</code> of class
                              <code class="literal">NullPointerException</code> is created and thrown instead of <code class="literal">null</code>. The <code class="literal">throw</code>
                              statement then completes abruptly, the reason being a <code class="literal">throw</code>
                              with value <code class="varname">V'</code>.
                     </p>
                  </li>
               </ul>
            </div>
            <p class="note">It can be seen, then, that a <code class="literal">throw</code> statement
               always completes abruptly.
            </p>
            <p class="norm-dynamic"><a name="jls-14.18-500"></a>If there
               are any enclosing <code class="literal">try</code> statements (<a class="xref" href="jls-14.html#jls-14.20" title="14.20.&nbsp;The try statement">&sect;14.20</a>) whose
               <code class="literal">try</code> blocks contain the <code class="literal">throw</code> statement, then any <code class="literal">finally</code> clauses
               of those <code class="literal">try</code> statements are executed as control is transferred
               outward, until the thrown value is caught. Note that abrupt completion
               of a <code class="literal">finally</code> clause can disrupt the transfer of control initiated by
               a <code class="literal">throw</code> statement.
            </p>
            <p class="norm-dynamic"><a name="jls-14.18-510"></a>If a <code class="literal">throw</code>
               statement is contained in a method declaration or a lambda expression,
               but its value is not caught by some <code class="literal">try</code> statement that contains it,
               then the invocation of the method completes abruptly because of the
               <code class="literal">throw</code>.
            </p>
            <p class="norm-dynamic"><a name="jls-14.18-520"></a>If a
               <code class="literal">throw</code> statement is contained in a constructor declaration, but its
               value is not caught by some <code class="literal">try</code> statement that contains it, then the
               class instance creation expression that invoked the constructor will
               complete abruptly because of the <code class="literal">throw</code>
               (<a class="xref" href="jls-15.html#jls-15.9.4" title="15.9.4.&nbsp;Run-Time Evaluation of Class Instance Creation Expressions">&sect;15.9.4</a>).
            </p>
            <p class="norm-dynamic"><a name="jls-14.18-530"></a>If a
               <code class="literal">throw</code> statement is contained in a static initializer
               (<a class="xref" href="jls-8.html#jls-8.7" title="8.7.&nbsp;Static Initializers">&sect;8.7</a>), then a compile-time check
               (<a class="xref" href="jls-11.html#jls-11.2.3" title="11.2.3.&nbsp;Exception Checking">&sect;11.2.3</a>) ensures that either its value is always
               an unchecked exception or its value is always caught by some <code class="literal">try</code>
               statement that contains it. If at run time, despite this check, the
               value is not caught by some <code class="literal">try</code> statement that contains the <code class="literal">throw</code>
               statement, then the value is rethrown if it is an instance of class
               <code class="literal">Error</code> or one of its subclasses; otherwise, it is wrapped in an
               <code class="literal">ExceptionInInitializerError</code> object, which is then thrown
               (<a class="xref" href="jls-12.html#jls-12.4.2" title="12.4.2.&nbsp;Detailed Initialization Procedure">&sect;12.4.2</a>).
            </p>
            <p class="norm-dynamic"><a name="jls-14.18-540"></a>If a
               <code class="literal">throw</code> statement is contained in an instance initializer
               (<a class="xref" href="jls-8.html#jls-8.6" title="8.6.&nbsp;Instance Initializers">&sect;8.6</a>), then a compile-time check
               (<a class="xref" href="jls-11.html#jls-11.2.3" title="11.2.3.&nbsp;Exception Checking">&sect;11.2.3</a>) ensures that either its value is always
               an unchecked exception or its value is always caught by some <code class="literal">try</code>
               statement that contains it, or the type of the thrown exception (or
               one of its superclasses) occurs in the <code class="literal">throws</code> clause of every
               constructor of the class.
            </p>
            <p class="note">By convention, user-declared throwable types should
               usually be declared to be subclasses of class <code class="literal">Exception</code>, which is a
               subclass of class <code class="literal">Throwable</code> (<a class="xref" href="jls-11.html#jls-11.1.1" title="11.1.1.&nbsp;The Kinds of Exceptions">&sect;11.1.1</a>).
            </p>
         </div>
         <div class="section" title="14.19.&nbsp;The synchronized Statement">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-14.19"></a>14.19.&nbsp;The <code class="literal">synchronized</code> Statement
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm"><a name="jls-14.19-100"></a>A <code class="literal">synchronized</code> statement
               acquires a mutual-exclusion lock (<a class="xref" href="jls-17.html#jls-17.1" title="17.1.&nbsp;Synchronization">&sect;17.1</a>) on
               behalf of the executing thread, executes a block, then releases the
               lock. While the executing thread owns the lock, no other thread may
               acquire the lock.
            </p>
            <div id="jls-14.19-110" class="productionset"><a name="jls-14.19-110"></a>
                 
               <div class="production"><a name="jls-SynchronizedStatement"></a>
                      
                  <div class="lhs">SynchronizedStatement:</div>
                      
                  <div class="rhs">
                           <code class="literal">synchronized</code>
                           <code class="literal">(</code> <a href="jls-15.html#jls-Expression" title="Expression">Expression</a> <code class="literal">)</code>
                           <a href="jls-14.html#jls-Block" title="Block">Block</a>
                         
                  </div>
                    
               </div>
               
            </div>
            <p class="norm-error"><a name="jls-14.19-200"></a>The type of
               <span class="emphasis"><em>Expression</em></span> must be a reference type, or a compile-time error
               occurs.
            </p>
            <p class="norm-dynamic"><a name="jls-14.19-300"></a>
               A <code class="literal">synchronized</code> statement is executed by first evaluating the
               <span class="emphasis"><em>Expression</em></span>. Then:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.19-300-A"></a>
                              If evaluation of the <span class="emphasis"><em>Expression</em></span> completes abruptly for some
                              reason, then the <code class="literal">synchronized</code> statement completes abruptly for
                              the same reason.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-error"><a name="jls-14.19-300-B"></a>
                              Otherwise, if the value of the <span class="emphasis"><em>Expression</em></span> is <code class="literal">null</code>, a <code class="literal">NullPointerException</code>
                              is thrown.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-dynamic"><a name="jls-14.19-300-C"></a>
                              Otherwise, let the non-<code class="literal">null</code> value of the <span class="emphasis"><em>Expression</em></span>
                              be <code class="varname">V</code>. The executing thread locks
                              the monitor associated
                              with <code class="varname">V</code>. Then the <span class="emphasis"><em>Block</em></span> is executed, and
                              then there is a choice:
                     </p>
                     <div class="norm">
                        <ul class="norm" type="circle">
                           <li class="listitem">
                              <p class="norm-dynamic"><a name="jls-14.19-300-C-A"></a>
                                 	  If execution of the <span class="emphasis"><em>Block</em></span> completes normally, then
                                           the monitor is unlocked and the <code class="literal">synchronized</code>
                                           statement completes normally.
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="norm-dynamic"><a name="jls-14.19-300-C-B"></a>
                                 	  If execution of the <span class="emphasis"><em>Block</em></span> completes abruptly for any
                                           reason, then the monitor is unlocked and the
                                           <code class="literal">synchronized</code> statement completes abruptly for the same
                                           reason.
                              </p>
                           </li>
                        </ul>
                     </div>
                  </li>
               </ul>
            </div>
            <p class="norm-dynamic"><a name="jls-14.19-400"></a>The locks
               acquired by <code class="literal">synchronized</code> statements are the same as the locks that
               are acquired implicitly by <code class="literal">synchronized</code> methods
               (<a class="xref" href="jls-8.html#jls-8.4.3.6" title="8.4.3.6.&nbsp;synchronized Methods">&sect;8.4.3.6</a>). A single thread
               may acquire a lock more than once.
            </p>
            <p class="norm-dynamic"><a name="jls-14.19-410"></a>Acquiring
               the lock associated with an object does not in itself prevent other
               threads from accessing fields of the object or invoking
               un-<code class="literal">synchronized</code> methods on the object. Other threads can also use
               <code class="literal">synchronized</code> methods or the <code class="literal">synchronized</code> statement in a
               conventional manner to achieve mutual exclusion.
            </p>
            <div class="example"><a name="d5e21619"></a><p class="title"><b>Example&nbsp;14.19-1.&nbsp;The <code class="literal">synchronized</code> Statement</b></p>
               <div class="example-contents"><pre class="programlisting">
class Test {
    public static void main(String[] args) {
        Test t = new Test();
        synchronized(t) {
            synchronized(t) {
                System.out.println("made it!");
            }
        }
    }
}
</pre><p class="note">This program produces the output:</p><pre class="screen">
made it!
</pre><p class="note">Note that this program would deadlock if a single
                     thread were not permitted to lock a monitor more than
                     once.
                  </p>
               </div>
            </div><br class="example-break"></div>
         <div class="section" title="14.20.&nbsp;The try statement">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-14.20"></a>14.20.&nbsp;The <code class="literal">try</code> statement
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm-dynamic"><a name="jls-14.20-100"></a>A <code class="literal">try</code>
               statement executes a block. If a value is thrown and the <code class="literal">try</code>
               statement has one or more <code class="literal">catch</code> clauses that can catch it, then
               control will be transferred to the first such <code class="literal">catch</code> clause. If the
               <code class="literal">try</code> statement has a <code class="literal">finally</code> clause, then another block of code is
               executed, no matter whether the <code class="literal">try</code> block completes normally or
               abruptly, and no matter whether a <code class="literal">catch</code> clause is first given
               control.
            </p>
            <div id="jls-14.20-110" class="productionset"><a name="jls-14.20-110"></a>
                 
               <div class="production"><a name="jls-TryStatement"></a>
                      
                  <div class="lhs">TryStatement:</div>
                      
                  <div class="rhs">
                           <code class="literal">try</code> <a href="jls-14.html#jls-Block" title="Block">Block</a> <a href="jls-14.html#jls-Catches" title="Catches">Catches</a> <br>
                           <code class="literal">try</code> <a href="jls-14.html#jls-Block" title="Block">Block</a> [<a href="jls-14.html#jls-Catches" title="Catches">Catches</a>] <a href="jls-14.html#jls-Finally" title="Finally">Finally</a> <br>
                           <a href="jls-14.html#jls-TryWithResourcesStatement" title="TryWithResourcesStatement">TryWithResourcesStatement</a>
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-Catches"></a>
                      
                  <div class="lhs">Catches:</div>
                      
                  <div class="rhs">
                           <a href="jls-14.html#jls-CatchClause" title="CatchClause">CatchClause</a> {<a href="jls-14.html#jls-CatchClause" title="CatchClause">CatchClause</a>}
                         
                  </div>
                    
               </div>
                     
                 
               <div class="production"><a name="jls-CatchClause"></a>
                      
                  <div class="lhs">CatchClause:</div>
                      
                  <div class="rhs">
                           <code class="literal">catch</code>
                           <code class="literal">(</code> <a href="jls-14.html#jls-CatchFormalParameter" title="CatchFormalParameter">CatchFormalParameter</a> <code class="literal">)</code>
                           <a href="jls-14.html#jls-Block" title="Block">Block</a>
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-CatchFormalParameter"></a>
                      
                  <div class="lhs">CatchFormalParameter:</div>
                      
                  <div class="rhs">
                           {<a href="jls-8.html#jls-VariableModifier" title="VariableModifier">VariableModifier</a>}
                           <a href="jls-14.html#jls-CatchType" title="CatchType">CatchType</a>
                           <a href="jls-8.html#jls-VariableDeclaratorId" title="VariableDeclaratorId">VariableDeclaratorId</a>
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-CatchType"></a>
                      
                  <div class="lhs">CatchType:</div>
                      
                  <div class="rhs">
                           <a href="jls-8.html#jls-UnannClassType" title="UnannClassType">UnannClassType</a>
                           {<code class="literal">|</code> <a href="jls-4.html#jls-ClassType" title="ClassType">ClassType</a>}
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-Finally"></a>
                      
                  <div class="lhs">Finally:</div>
                      
                  <div class="rhs">
                           <code class="literal">finally</code> <a href="jls-14.html#jls-Block" title="Block">Block</a>
                         
                  </div>
                    
               </div>
               
            </div>
            <p class="note">See <a class="xref" href="jls-8.html#jls-8.3" title="8.3.&nbsp;Field Declarations">&sect;8.3</a> for 
               <span class="emphasis"><em>UnannClassType</em></span>. The following productions from
               <a class="xref" href="jls-4.html#jls-4.3" title="4.3.&nbsp;Reference Types and Values">&sect;4.3</a>, <a class="xref" href="jls-8.html#jls-8.3" title="8.3.&nbsp;Field Declarations">&sect;8.3</a>, and
               <a class="xref" href="jls-8.html#jls-8.4.1" title="8.4.1.&nbsp;Formal Parameters">&sect;8.4.1</a> are shown here for convenience:
            </p>
            <div id="d5e21686" class="productionset"><a name="d5e21686"></a>
                 
               <div class="productionrecap-note">
                  <div class="production">
                         
                     <div class="lhs">VariableModifier:</div>
                         
                     <div class="rhs">
                              <a href="jls-9.html#jls-Annotation" title="Annotation">Annotation</a> <code class="literal">final</code>
                            
                     </div>
                       
                  </div>
               </div>
                 
               <div class="productionrecap-note">
                  <div class="production">
                         
                     <div class="lhs">VariableDeclaratorId:</div>
                         
                     <div class="rhs">
                              <a href="jls-3.html#jls-Identifier" title="Identifier">Identifier</a> [<a href="jls-4.html#jls-Dims" title="Dims">Dims</a>]
                            
                     </div>
                       
                  </div>
               </div>
                 
               <div class="productionrecap-note">
                  <div class="production">
                         
                     <div class="lhs">Dims:</div>
                         
                     <div class="rhs">
                              {<a href="jls-9.html#jls-Annotation" title="Annotation">Annotation</a>} <code class="literal">[</code> <code class="literal">]</code> {{<a href="jls-9.html#jls-Annotation" title="Annotation">Annotation</a>} <code class="literal">[</code> <code class="literal">]</code>}
                            
                     </div>
                       
                  </div>
               </div>
               
            </div>
            <p class="norm"><a name="jls-14.20-200"></a>The <span class="emphasis"><em>Block</em></span> immediately after
               the keyword <code class="literal">try</code> is called the <span class="emphasis"><em><code class="literal">try</code> block</em></span> of
               the <code class="literal">try</code> statement.
            </p>
            <p class="norm"><a name="jls-14.20-210"></a>The <span class="emphasis"><em>Block</em></span> immediately after
               the keyword <code class="literal">finally</code> is called the <span class="emphasis"><em><code class="literal">finally</code>
                     block</em></span> of the <code class="literal">try</code> statement.
            </p>
            <p class="norm"><a name="jls-14.20-300"></a>A <code class="literal">try</code> statement may have
               <code class="literal">catch</code> clauses, also called <span class="emphasis"><em>exception
                     handlers</em></span>.
            </p>
            <p class="norm"><a name="jls-14.20-310"></a>A <code class="literal">catch</code> clause declares
               exactly one parameter, which is called an <span class="emphasis"><em>exception
                     parameter</em></span>.
            </p>
            <p class="norm-error"><a name="jls-14.20-320"></a>It is a
               compile-time error if <code class="literal">final</code> appears more than once as a modifier for
               an exception parameter declaration.
            </p>
            <p class="norm-static"><a name="jls-14.20-330"></a>The scope
               and shadowing of an exception parameter is specified in
               <a class="xref" href="jls-6.html#jls-6.3" title="6.3.&nbsp;Scope of a Declaration">&sect;6.3</a> and <a class="xref" href="jls-6.html#jls-6.4" title="6.4.&nbsp;Shadowing and Obscuring">&sect;6.4</a>.
            </p>
            <p class="norm-static"><a name="jls-14.20-400"></a>An exception
               parameter may denote its type as either a single class type or a union
               of two or more class types
               (called <span class="emphasis"><em>alternatives</em></span>). The alternatives of a
               union are syntactically separated by <code class="literal">|</code>.
            </p>
            <p class="norm"><a name="jls-14.20-410"></a>A <code class="literal">catch</code> clause whose exception
               parameter is denoted as a single class type is called
               a <span class="emphasis"><em>uni-<code class="literal">catch</code> clause</em></span>.
            </p>
            <p class="norm"><a name="jls-14.20-420"></a>A <code class="literal">catch</code> clause whose exception
               parameter is denoted as a union of types is called
               a <span class="emphasis"><em>multi-<code class="literal">catch</code> clause</em></span>.
            </p>
            <p class="norm-error"><a name="jls-14.20-430"></a>Each class type
               used in the denotation of the type of an exception parameter must be
               the class <code class="literal">Throwable</code> or a subclass  of
               <code class="literal">Throwable</code>, or a compile-time error occurs.
            </p>
            <p class="norm-error"><a name="jls-14.20-440"></a>It is a
               compile-time error if a type variable is used in the denotation of the
               type of an exception parameter.
            </p>
            <p class="norm-error"><a name="jls-14.20-450"></a>It is a
               compile-time error if a union of types contains two alternatives <span class="type">D<sub>i</sub></span>
               and <span class="type">D<sub>j</sub></span> (<span class="emphasis"><em>i</em></span> <span class="symbol">&#8800;</span> <span class="emphasis"><em>j</em></span>) where <span class="type">D<sub>i</sub></span> is a subtype of <span class="type">D<sub>j</sub></span>
               (<a class="xref" href="jls-4.html#jls-4.10.2" title="4.10.2.&nbsp;Subtyping among Class and Interface Types">&sect;4.10.2</a>).
            </p>
            <p class="norm-static"><a name="jls-14.20-500"></a>The declared type
               of an exception parameter that denotes its type with a single class
               type is that class type.
            </p>
            <p class="norm-static"><a name="jls-14.20-510"></a>The declared type
               of an exception parameter that denotes its type as a union with
               alternatives <span class="type">D<sub>1</sub></span> <code class="literal">|</code> <span class="type">D<sub>2</sub></span> <code class="literal">|</code> ... <code class="literal">|</code> <span class="type">D<sub>n</sub></span> is lub(<span class="type">D<sub>1</sub></span>, <span class="type">D<sub>2</sub></span>,
               ..., <span class="type">D<sub>n</sub></span>).
            </p>
            <p class="norm-static"><a name="jls-14.20-600"></a>An exception
               parameter of a multi-<code class="literal">catch</code> clause is implicitly declared <code class="literal">final</code> if
               it is not explicitly declared <code class="literal">final</code>.
            </p>
            <p class="norm-error"><a name="jls-14.20-610"></a>It is a
               compile-time error if an exception parameter that
               is implicitly or explicitly declared <code class="literal">final</code> is
               assigned to within the body of the <code class="literal">catch</code> clause.
            </p>
            <p class="norm-static"><a name="jls-14.20-620"></a>An exception
               parameter of a uni-<code class="literal">catch</code> clause is never implicitly declared
               <code class="literal">final</code>, but it may be explicitly declared <code class="literal">final</code> or be effectively
               final (<a class="xref" href="jls-4.html#jls-4.12.4" title="4.12.4.&nbsp;final Variables">&sect;4.12.4</a>).
            </p>
            <p class="note">An implicitly <code class="literal">final</code> exception parameter is final
               by virtue of its declaration, while an effectively final exception
               parameter is (as it were) final by virtue of how it is used. An
               exception parameter of a multi-<code class="literal">catch</code> clause is implicitly declared
               <code class="literal">final</code>, so will never occur as the left-hand operand of an assignment
               operator, but it is <span class="emphasis"><em>not</em></span> considered effectively
               final.
            </p>
            <p class="note">If an exception parameter is effectively final (in a
               uni-<code class="literal">catch</code> clause) or implicitly final (in a multi-<code class="literal">catch</code> clause),
               then adding an explicit <code class="literal">final</code> modifier to its declaration will not
               introduce any compile-time errors. On the other hand, if the exception
               parameter of a uni-<code class="literal">catch</code> clause is explicitly declared <code class="literal">final</code>, then
               removing the <code class="literal">final</code> modifier may introduce compile-time errors
               because the exception parameter, now considered to be effectively
               final, can no longer longer be referenced by anonymous and local class
               declarations in the body of the <code class="literal">catch</code> clause. If there are no
               compile-time errors, it is possible to further change the program so
               that the exception parameter is re-assigned in the body of the <code class="literal">catch</code>
               clause and thus will no longer be considered effectively final.
            </p>
            <p class="norm-static"><a name="jls-14.20-700"></a>The
               exception types that a <code class="literal">try</code> statement can throw are specified in
               <a class="xref" href="jls-11.html#jls-11.2.2" title="11.2.2.&nbsp;Exception Analysis of Statements">&sect;11.2.2</a>.
            </p>
            <p class="norm-static"><a name="jls-14.20-710"></a>The
               relationship of the exceptions thrown by the <code class="literal">try</code> block of a <code class="literal">try</code>
               statement and caught by the <code class="literal">catch</code> clauses (if any) of the <code class="literal">try</code>
               statement is specified in <a class="xref" href="jls-11.html#jls-11.2.3" title="11.2.3.&nbsp;Exception Checking">&sect;11.2.3</a>.
            </p>
            <p class="norm-dynamic"><a name="jls-14.20-720"></a>Exception
               handlers are considered in left-to-right order: the earliest possible
               <code class="literal">catch</code> clause accepts the exception, receiving as its argument the
               thrown exception object, as specified in
               <a class="xref" href="jls-11.html#jls-11.3" title="11.3.&nbsp;Run-Time Handling of an Exception">&sect;11.3</a>.
            </p>
            <div class="informalexample">
               <p class="note">A multi-<code class="literal">catch</code> clause can be thought of as a
                  sequence of uni-<code class="literal">catch</code> clauses. That is, a <code class="literal">catch</code> clause where the
                  type of the exception parameter is denoted as a union
                  <span class="type">D<sub>1</sub></span><code class="literal">|</code><span class="type">D<sub>2</sub></span><code class="literal">|</code>...<code class="literal">|</code><span class="type">D<sub>n</sub></span> is equivalent to a sequence of <span class="emphasis"><em>n</em></span>
                  <code class="literal">catch</code> clauses where the types of the exception parameters are class
                  types <span class="type">D<sub>1</sub></span>, <span class="type">D<sub>2</sub></span>, ..., <span class="type">D<sub>n</sub></span> respectively. In the <span class="emphasis"><em>Block</em></span> of each of
                  the <span class="emphasis"><em>n</em></span> <code class="literal">catch</code> clauses, the declared type of the exception
                  parameter is lub(<span class="type">D<sub>1</sub></span>, <span class="type">D<sub>2</sub></span>, ..., <span class="type">D<sub>n</sub></span>). For example, the following
                  code:
               </p><pre class="screen">
try {
    ... throws ReflectiveOperationException ...
}
catch (ClassNotFoundException | IllegalAccessException ex) {
    ... body ...
}
</pre><p class="note">is semantically equivalent to the following
                  code:
               </p><pre class="screen">
try {
    ... throws ReflectiveOperationException ...
}
catch (final ClassNotFoundException ex1) {
    final ReflectiveOperationException ex = ex1;
    ... body ...
}
catch (final IllegalAccessException ex2) {
    final ReflectiveOperationException ex = ex2;
    ... body ...
}
</pre><p class="note">where the multi-<code class="literal">catch</code> clause with two alternatives
                  has been translated into two uni-<code class="literal">catch</code> clauses, one for each
                  alternative. A Java compiler is neither required nor recommended to
                  compile a multi-<code class="literal">catch</code> clause by duplicating code in this manner,
                  since it is possible to represent the multi-<code class="literal">catch</code> clause in a
                  <code class="literal">class</code> file without duplication.
               </p>
            </div>
            <p class="norm"><a name="jls-14.20-800"></a>A <code class="literal">finally</code> clause ensures
               that the <code class="literal">finally</code> block is executed after the <code class="literal">try</code> block and any
               <code class="literal">catch</code> block that might be executed, no matter how control leaves the
               <code class="literal">try</code> block or <code class="literal">catch</code> block. Handling of the <code class="literal">finally</code> block is
               rather complex, so the two cases of a <code class="literal">try</code> statement with and without
               a <code class="literal">finally</code> block are described separately
               (<a class="xref" href="jls-14.html#jls-14.20.1" title="14.20.1.&nbsp;Execution of try-catch">&sect;14.20.1</a>, <a class="xref" href="jls-14.html#jls-14.20.2" title="14.20.2.&nbsp;Execution of try-finally and try-catch-finally">&sect;14.20.2</a>).
            </p>
            <p class="norm"><a name="jls-14.20-900"></a>A <code class="literal">try</code> statement is permitted to omit
               <code class="literal">catch</code> clauses and a <code class="literal">finally</code> clause if it is
               a <span class="emphasis"><em><code class="literal">try</code>-with-resources</em></span> statement
               (<a class="xref" href="jls-14.html#jls-14.20.3" title="14.20.3.&nbsp;try-with-resources">&sect;14.20.3</a>).
            </p>
            <div class="section" title="14.20.1.&nbsp;Execution of try-catch">
               <div class="titlepage">
                  <div>
                     <div>
                        <h3 class="title"><a name="jls-14.20.1"></a>14.20.1.&nbsp;Execution of <code class="literal">try</code>-<code class="literal">catch</code></h3>
                     </div>
                  </div>
               </div>
               <p class="norm-dynamic"><a name="jls-14.20.1-100"></a>
                  A <code class="literal">try</code> statement without a <code class="literal">finally</code> block is executed by first
                  executing the <code class="literal">try</code> block. Then there is a choice:
               </p>
               <div class="norm">
                  <ul class="norm" type="disc">
                     <li class="listitem">
                        <p class="norm-dynamic"><a name="jls-14.20.1-100-A"></a>
                                 If execution of the <code class="literal">try</code> block completes normally, then no
                                 further action is taken and the <code class="literal">try</code> statement completes
                                 normally.
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="norm-dynamic"><a name="jls-14.20.1-100-B"></a>
                                 If execution of the <code class="literal">try</code> block completes abruptly because of a
                                 <code class="literal">throw</code> of a value <code class="varname">V</code>, then there is a
                                 choice:
                        </p>
                        <div class="norm">
                           <ul class="norm" type="circle">
                              <li class="listitem">
                                 <p class="norm-dynamic"><a name="jls-14.20.1-100-B-A"></a>
                                    	  If the run-time type of <code class="varname">V</code> is assignment
                                    	  compatible with (<a class="xref" href="jls-5.html#jls-5.2" title="5.2.&nbsp;Assignment Contexts">&sect;5.2</a>) a catchable
                                    	  exception class of any <code class="literal">catch</code> clause of the <code class="literal">try</code>
                                    	  statement, then the first (leftmost) such <code class="literal">catch</code> clause is
                                    	  selected. The value <code class="varname">V</code> is assigned to the
                                    	  parameter of the selected <code class="literal">catch</code> clause, and the <span class="emphasis"><em>Block</em></span> of
                                    	  that <code class="literal">catch</code> clause is executed, and then there is a
                                    	  choice:
                                 </p>
                                 <div class="norm">
                                    <ul class="norm" type="square">
                                       <li class="listitem">
                                          <p class="norm-dynamic"><a name="jls-14.20.1-100-B-A-A"></a>
                                             	      If that block completes normally, then the <code class="literal">try</code>
                                             	      statement completes normally.
                                          </p>
                                       </li>
                                       <li class="listitem">
                                          <p class="norm-dynamic"><a name="jls-14.20.1-100-B-A-B"></a>
                                             	      If that block completes abruptly for any reason, then
                                             	      the <code class="literal">try</code> statement completes abruptly for the same
                                             	      reason.
                                          </p>
                                       </li>
                                    </ul>
                                 </div>
                              </li>
                              <li class="listitem">
                                 <p class="norm-dynamic"><a name="jls-14.20.1-100-B-B"></a>
                                    	  If the run-time type of <code class="varname">V</code> is not
                                    	  assignment compatible with a catchable exception class of
                                    	  any <code class="literal">catch</code> clause of the <code class="literal">try</code> statement, then the <code class="literal">try</code>
                                    	  statement completes abruptly because of a <code class="literal">throw</code> of the
                                    	  value <code class="varname">V</code>.
                                 </p>
                              </li>
                           </ul>
                        </div>
                     </li>
                     <li class="listitem">
                        <p class="norm-dynamic"><a name="jls-14.20.1-100-C"></a>
                                 If execution of the <code class="literal">try</code> block completes abruptly for any other
                                 reason, then the <code class="literal">try</code> statement completes abruptly for the same
                                 reason.
                        </p>
                     </li>
                  </ul>
               </div>
               <div class="example"><a name="d5e21905"></a><p class="title"><b>Example&nbsp;14.20.1-1.&nbsp;Catching An Exception</b></p>
                  <div class="example-contents"><pre class="programlisting">
class BlewIt extends Exception {
    BlewIt() { }
    BlewIt(String s) { super(s); }
}
class Test {
    static void blowUp() throws BlewIt { throw new BlewIt(); }

    public static void main(String[] args) {
        try {
            blowUp();
        } catch (RuntimeException r) {
            System.out.println("Caught RuntimeException");
        } catch (BlewIt b) {
            System.out.println("Caught BlewIt");
        }
    }
}
</pre><p class="note">Here, the exception <code class="literal">BlewIt</code> is
                        thrown by the method <code class="literal">blowUp</code>. The <code class="literal">try</code>-<code class="literal">catch</code>
                        statement in the body of <code class="literal">main</code> has two <code class="literal">catch</code>
                        clauses. The run-time type of the exception
                        is <code class="literal">BlewIt</code> which is not assignable to a variable of
                        type <code class="literal">RuntimeException</code>, but is assignable to a variable of
                        type <code class="literal">BlewIt</code>, so the output of the example
                        is:
                     </p><pre class="screen">
Caught BlewIt
</pre></div>
               </div><br class="example-break"></div>
            <div class="section" title="14.20.2.&nbsp;Execution of try-finally and try-catch-finally">
               <div class="titlepage">
                  <div>
                     <div>
                        <h3 class="title"><a name="jls-14.20.2"></a>14.20.2.&nbsp;Execution of <code class="literal">try</code>-<code class="literal">finally</code> and <code class="literal">try</code>-<code class="literal">catch</code>-<code class="literal">finally</code></h3>
                     </div>
                  </div>
               </div>
               <p class="norm-dynamic"><a name="jls-14.20.2-100"></a>
                  A <code class="literal">try</code> statement with a <code class="literal">finally</code> block is executed by first
                  executing the <code class="literal">try</code> block. Then there is a choice:
               </p>
               <div class="norm">
                  <ul class="norm" type="disc">
                     <li class="listitem">
                        <p class="norm-dynamic"><a name="jls-14.20.2-100-A"></a>
                                 If execution of the <code class="literal">try</code> block completes normally, then the
                                 <code class="literal">finally</code> block is executed, and then there is a choice:
                        </p>
                        <div class="norm">
                           <ul class="norm" type="circle">
                              <li class="listitem">
                                 <p class="norm-dynamic"><a name="jls-14.20.2-100-A-A"></a>
                                    	  If the <code class="literal">finally</code> block completes normally, then the <code class="literal">try</code>
                                    	  statement completes normally.
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-dynamic"><a name="jls-14.20.2-100-A-B"></a>
                                    	  If the <code class="literal">finally</code> block completes abruptly for
                                    	  reason <code class="varname">S</code>, then the <code class="literal">try</code> statement
                                    	  completes abruptly for reason <code class="varname">S</code>.
                                 </p>
                              </li>
                           </ul>
                        </div>
                     </li>
                     <li class="listitem">
                        <p class="norm-dynamic"><a name="jls-14.20.2-100-B"></a>
                                 If execution of the <code class="literal">try</code> block completes abruptly because of a
                                 <code class="literal">throw</code> of a value <code class="varname">V</code>, then there is a
                                 choice:
                        </p>
                        <div class="norm">
                           <ul class="norm" type="circle">
                              <li class="listitem">
                                 <p class="norm-dynamic"><a name="jls-14.20.2-100-B-A"></a>
                                    	  If the run-time type of <code class="varname">V</code> is assignment
                                    	  compatible with a catchable exception class of any <code class="literal">catch</code>
                                    	  clause of the <code class="literal">try</code> statement, then the first (leftmost)
                                    	  such <code class="literal">catch</code> clause is selected. The
                                    	  value <code class="varname">V</code> is assigned to the parameter of
                                    	  the selected <code class="literal">catch</code> clause, and the <span class="emphasis"><em>Block</em></span> of that <code class="literal">catch</code>
                                    	  clause is executed. Then there is a choice:
                                 </p>
                                 <div class="norm">
                                    <ul class="norm" type="square">
                                       <li class="listitem">
                                          <p class="norm-dynamic"><a name="jls-14.20.2-100-B-A-A"></a>
                                             	      If the <code class="literal">catch</code> block completes normally, then the
                                             	      <code class="literal">finally</code> block is executed. Then there is a
                                             	      choice:
                                          </p>
                                          <div class="norm">
                                             <ul class="norm" type="disc">
                                                <li class="listitem">
                                                   <p class="norm-dynamic"><a name="jls-14.20.2-100-B-A-A-A"></a>
                                                      		  If the <code class="literal">finally</code> block completes normally, then the
                                                      	          <code class="literal">try</code> statement completes normally.
                                                   </p>
                                                </li>
                                                <li class="listitem">
                                                   <p class="norm-dynamic"><a name="jls-14.20.2-100-B-A-A-B"></a>
                                                      		  If the <code class="literal">finally</code> block completes abruptly for any
                                                        	          reason, then the <code class="literal">try</code> statement completes abruptly
                                                        	          for the same reason.
                                                   </p>
                                                </li>
                                             </ul>
                                          </div>
                                       </li>
                                       <li class="listitem">
                                          <p class="norm-dynamic"><a name="jls-14.20.2-100-B-A-B"></a>
                                             	      If the <code class="literal">catch</code> block completes abruptly for
                                             	      reason <code class="varname">R</code>, then the <code class="literal">finally</code> block is
                                             	      executed. Then there is a choice:
                                          </p>
                                          <div class="norm">
                                             <ul class="norm" type="disc">
                                                <li class="listitem">
                                                   <p class="norm-dynamic"><a name="jls-14.20.2-100-B-A-B-A"></a>
                                                      		  If the <code class="literal">finally</code> block completes normally, then the
                                                      		  <code class="literal">try</code> statement completes abruptly for
                                                      		  reason <code class="varname">R</code>.
                                                   </p>
                                                </li>
                                                <li class="listitem">
                                                   <p class="norm-dynamic"><a name="jls-14.20.2-100-B-A-B-B"></a>
                                                      		  If the <code class="literal">finally</code> block completes abruptly for
                                                      		  reason <code class="varname">S</code>, then the <code class="literal">try</code>
                                                      		  statement completes abruptly for
                                                      		  reason <code class="varname">S</code> (and
                                                      		  reason <code class="varname">R</code> is discarded).
                                                   </p>
                                                </li>
                                             </ul>
                                          </div>
                                       </li>
                                    </ul>
                                 </div>
                              </li>
                              <li class="listitem">
                                 <p class="norm-dynamic"><a name="jls-14.20.2-100-B-B"></a>If the run-time type
                                    	of <code class="varname">V</code> is not assignment compatible with a
                                    	catchable exception class of any <code class="literal">catch</code> clause of the <code class="literal">try</code>
                                    	statement, then the <code class="literal">finally</code> block is executed. Then there is
                                    	a choice:
                                 </p>
                                 <div class="norm">
                                    <ul class="norm" type="square">
                                       <li class="listitem">
                                          <p class="norm-dynamic"><a name="jls-14.20.2-100-B-B-A"></a>If the <code class="literal">finally</code> block
                                             	    completes normally, then the <code class="literal">try</code> statement completes
                                             	    abruptly because of a <code class="literal">throw</code> of the
                                             	    value <code class="varname">V</code>.
                                          </p>
                                       </li>
                                       <li class="listitem">
                                          <p class="norm-error"><a name="jls-14.20.2-100-B-B-B"></a>If the <code class="literal">finally</code> block
                                             	    completes abruptly for reason <code class="varname">S</code>, then
                                             	    the <code class="literal">try</code> statement completes abruptly for
                                             	    reason <code class="varname">S</code> (and the <code class="literal">throw</code> of
                                             	    value <code class="varname">V</code> is discarded and
                                             	    forgotten).
                                          </p>
                                       </li>
                                    </ul>
                                 </div>
                              </li>
                           </ul>
                        </div>
                     </li>
                     <li class="listitem">
                        <p class="norm-dynamic"><a name="jls-14.20.2-100-C"></a>
                                 If execution of the <code class="literal">try</code> block completes abruptly for any other
                                 reason <code class="varname">R</code>, then the <code class="literal">finally</code> block is
                                 executed, and then there is a choice:
                        </p>
                        <div class="norm">
                           <ul class="norm" type="circle">
                              <li class="listitem">
                                 <p class="norm-dynamic"><a name="jls-14.20.2-100-C-A"></a>
                                    	  If the <code class="literal">finally</code> block completes normally, then the <code class="literal">try</code>
                                    	  statement completes abruptly for
                                    	  reason <code class="varname">R</code>.
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-dynamic"><a name="jls-14.20.2-100-C-B"></a>
                                    	  If the <code class="literal">finally</code> block completes abruptly for
                                    	  reason <code class="varname">S</code>, then the <code class="literal">try</code> statement
                                    	  completes abruptly for reason <code class="varname">S</code> (and
                                    	  reason <code class="varname">R</code> is discarded).
                                 </p>
                              </li>
                           </ul>
                        </div>
                     </li>
                  </ul>
               </div>
               <div class="example"><a name="d5e22033"></a><p class="title"><b>Example&nbsp;14.20.2-1.&nbsp;Handling An Uncaught Exception With <code class="literal">finally</code></b></p>
                  <div class="example-contents"><pre class="programlisting">
class BlewIt extends Exception {
    BlewIt() { }
    BlewIt(String s) { super(s); }
}
class Test {
    static void blowUp() throws BlewIt {
        throw new NullPointerException();
    }
    public static void main(String[] args) {
        try {
            blowUp();
        } catch (BlewIt b) {
            System.out.println("Caught BlewIt");
        } finally {
            System.out.println("Uncaught Exception");
        }
    }
}
</pre><p class="note">This program produces the output:</p><pre class="screen">
Uncaught Exception
Exception in thread "main" java.lang.NullPointerException
        at Test.blowUp(Test.java:7)
        at Test.main(Test.java:11)
</pre><p class="note">The <code class="literal">NullPointerException</code> (which is a kind of <code class="literal">RuntimeException</code>)
                        that is thrown by method <code class="literal">blowUp</code> is not caught by
                        the <code class="literal">try</code> statement in <code class="literal">main</code>, because a <code class="literal">NullPointerException</code> is not
                        assignable to a variable of type <code class="literal">BlewIt</code>. This
                        causes the <code class="literal">finally</code> clause to execute, after which the thread
                        executing <code class="literal">main</code>, which is the only thread of the
                        test program, terminates because of an uncaught exception, which
                        typically results in printing the exception name and a simple
                        backtrace. However, a backtrace is not required by this
                        specification.
                     </p>
                     <p class="note">The problem with mandating a backtrace is that an
                        exception can be created at one point in the program and thrown at a
                        later one. It is prohibitively expensive to store a stack trace in an
                        exception unless it is actually thrown (in which case the trace may be
                        generated while unwinding the stack). Hence we do not mandate a back
                        trace in every exception.
                     </p>
                  </div>
               </div><br class="example-break"></div>
            <div class="section" title="14.20.3.&nbsp;try-with-resources">
               <div class="titlepage">
                  <div>
                     <div>
                        <h3 class="title"><a name="jls-14.20.3"></a>14.20.3.&nbsp;<code class="literal">try</code>-with-resources
                        </h3>
                     </div>
                  </div>
               </div>
               <p class="norm"><a name="jls-14.20.3-100"></a>A <code class="literal">try</code>-with-resources
                  statement is parameterized with variables (known
                  as <span class="emphasis"><em>resources</em></span>) that are initialized before
                  execution of the <code class="literal">try</code> block and closed automatically, in the reverse
                  order from which they were initialized, after execution of the <code class="literal">try</code>
                  block. <code class="literal">catch</code> clauses and a <code class="literal">finally</code> clause are often unnecessary
                  when resources are closed automatically.
               </p>
               <div id="jls-14.20.3-110" class="productionset"><a name="jls-14.20.3-110"></a>
                    
                  <div class="production"><a name="jls-TryWithResourcesStatement"></a>
                         
                     <div class="lhs">TryWithResourcesStatement:</div>
                         
                     <div class="rhs">
                              <code class="literal">try</code>
                              <a href="jls-14.html#jls-ResourceSpecification" title="ResourceSpecification">ResourceSpecification</a>
                              <a href="jls-14.html#jls-Block" title="Block">Block</a>
                              [<a href="jls-14.html#jls-Catches" title="Catches">Catches</a>]
                              [<a href="jls-14.html#jls-Finally" title="Finally">Finally</a>]
                            
                     </div>
                       
                  </div>
                  
                    
                  <div class="production"><a name="jls-ResourceSpecification"></a>
                         
                     <div class="lhs">ResourceSpecification:</div>
                         
                     <div class="rhs">
                              <code class="literal">(</code> <a href="jls-14.html#jls-ResourceList" title="ResourceList">ResourceList</a> [<code class="literal">;</code>] <code class="literal">)</code>
                            
                     </div>
                       
                  </div>
                  
                    
                  <div class="production"><a name="jls-ResourceList"></a>
                         
                     <div class="lhs">ResourceList:</div>
                         
                     <div class="rhs">
                              <a href="jls-14.html#jls-Resource" title="Resource">Resource</a> {<code class="literal">;</code> <a href="jls-14.html#jls-Resource" title="Resource">Resource</a>}
                            
                     </div>
                       
                  </div>
                  
                    
                  <div class="production"><a name="jls-Resource"></a>
                         
                     <div class="lhs">Resource:</div>
                         
                     <div class="rhs">
                              {<a href="jls-8.html#jls-VariableModifier" title="VariableModifier">VariableModifier</a>}
                              <a href="jls-8.html#jls-UnannType" title="UnannType">UnannType</a>
                              <a href="jls-8.html#jls-VariableDeclaratorId" title="VariableDeclaratorId">VariableDeclaratorId</a>
                              <code class="literal">=</code> <a href="jls-15.html#jls-Expression" title="Expression">Expression</a>
                            
                     </div>
                       
                  </div>
                  
               </div>
               <p class="note">See <a class="xref" href="jls-8.html#jls-8.3" title="8.3.&nbsp;Field Declarations">&sect;8.3</a> for 
                  <span class="emphasis"><em>UnannType</em></span>. The following productions from
                  <a class="xref" href="jls-4.html#jls-4.3" title="4.3.&nbsp;Reference Types and Values">&sect;4.3</a>, <a class="xref" href="jls-8.html#jls-8.3" title="8.3.&nbsp;Field Declarations">&sect;8.3</a>, and
                  <a class="xref" href="jls-8.html#jls-8.4.1" title="8.4.1.&nbsp;Formal Parameters">&sect;8.4.1</a> are shown here for convenience:
               </p>
               <div id="d5e22096" class="productionset"><a name="d5e22096"></a>
                    
                  <div class="productionrecap-note">
                     <div class="production">
                            
                        <div class="lhs">VariableModifier:</div>
                            
                        <div class="rhs">
                                 <a href="jls-9.html#jls-Annotation" title="Annotation">Annotation</a> <code class="literal">final</code>
                               
                        </div>
                          
                     </div>
                  </div>
                    
                  <div class="productionrecap-note">
                     <div class="production">
                            
                        <div class="lhs">VariableDeclaratorId:</div>
                            
                        <div class="rhs">
                                 <a href="jls-3.html#jls-Identifier" title="Identifier">Identifier</a> [<a href="jls-4.html#jls-Dims" title="Dims">Dims</a>]
                               
                        </div>
                          
                     </div>
                  </div>
                    
                  <div class="productionrecap-note">
                     <div class="production">
                            
                        <div class="lhs">Dims:</div>
                            
                        <div class="rhs">
                                 {<a href="jls-9.html#jls-Annotation" title="Annotation">Annotation</a>} <code class="literal">[</code> <code class="literal">]</code> {{<a href="jls-9.html#jls-Annotation" title="Annotation">Annotation</a>} <code class="literal">[</code> <code class="literal">]</code>}
                               
                        </div>
                          
                     </div>
                  </div>
                  
               </div>
               <p class="norm-static"><a name="jls-14.20.3-200"></a>A <span class="emphasis"><em>resource specification</em></span>
                  declares one or more local variables with initializer expressions to
                  act as <span class="emphasis"><em>resources</em></span> for the <code class="literal">try</code> statement.
               </p>
               <p class="norm-error"><a name="jls-14.20.3-210"></a>It is a
                  compile-time error for a resource specification to declare two
                  variables with the same name.
               </p>
               <p class="norm-error"><a name="jls-14.20.3-220"></a>It is a
                  compile-time error if <code class="literal">final</code> appears more than once as a modifier for
                  each variable declared in a resource specification.
               </p>
               <p class="norm-static"><a name="jls-14.20.3-230"></a>A
                  variable declared in a resource specification is implicitly declared
                  <code class="literal">final</code> (<a class="xref" href="jls-4.html#jls-4.12.4" title="4.12.4.&nbsp;final Variables">&sect;4.12.4</a>) if it is not explicitly
                  declared <code class="literal">final</code>.
               </p>
               <p class="norm-error"><a name="jls-14.20.3-240"></a>The type
                  of a variable declared in a resource specification must be a subtype
                  of <code class="literal">AutoCloseable</code>, or a compile-time error occurs.
               </p>
               <p class="norm-static"><a name="jls-14.20.3-250"></a>The
                  scope and shadowing of a variable declared in a resource specification
                  is specified in <a class="xref" href="jls-6.html#jls-6.3" title="6.3.&nbsp;Scope of a Declaration">&sect;6.3</a> and
                  <a class="xref" href="jls-6.html#jls-6.4" title="6.4.&nbsp;Shadowing and Obscuring">&sect;6.4</a>.
               </p>
               <p class="norm-dynamic"><a name="jls-14.20.3-300"></a>
                  Resources are initialized in left-to-right order. If a resource fails
                  to initialize (that is, its initializer expression throws an
                  exception), then all resources initialized so far by the
                  <code class="literal">try</code>-with-resources statement are closed. If all resources initialize
                  successfully, the <code class="literal">try</code> block executes as normal and then all non-null
                  resources of the <code class="literal">try</code>-with-resources statement are closed.
               </p>
               <p class="norm-dynamic"><a name="jls-14.20.3-310"></a>
                  Resources are closed in the reverse order from that in which they were
                  initialized. A resource is closed only if it initialized to a non-null
                  value. An exception from the closing of one resource does not prevent
                  the closing of other resources. Such an exception
                  is <span class="emphasis"><em>suppressed</em></span> if an exception was thrown
                  previously by an initializer, the <code class="literal">try</code> block, or the closing of a
                  resource.
               </p>
               <p class="norm-dynamic"><a name="jls-14.20.3-320"></a>
                  A <code class="literal">try</code>-with-resources statement whose resource specification declares
                  multiple resources is treated as if it were multiple
                  <code class="literal">try</code>-with-resources statements, each of which has a resource
                  specification that declares a single resource. When a
                  <code class="literal">try</code>-with-resources statement with <span class="emphasis"><em>n</em></span> resources (<span class="emphasis"><em>n</em></span> &gt; 1)
                  is translated, the result is a <code class="literal">try</code>-with-resources statement with
                  <span class="emphasis"><em>n</em></span>-1 resources. After <span class="emphasis"><em>n</em></span> such translations, there are <span class="emphasis"><em>n</em></span>
                  nested <code class="literal">try</code>-<code class="literal">catch</code>-<code class="literal">finally</code> statements, and the overall translation
                  is complete.
               </p>
               <div class="section" title="14.20.3.1.&nbsp;Basic try-with-resources">
                  <div class="titlepage">
                     <div>
                        <div>
                           <h4 class="title"><a name="jls-14.20.3.1"></a>14.20.3.1.&nbsp;Basic <code class="literal">try</code>-with-resources
                           </h4>
                        </div>
                     </div>
                  </div>
                  <p class="norm-static"><a name="jls-14.20.3.1-100"></a>A
                     <code class="literal">try</code>-with-resources statement with no <code class="literal">catch</code> clauses or <code class="literal">finally</code>
                     clause is called a <span class="emphasis"><em>basic</em></span> <code class="literal">try</code>-with-resources
                     statement.
                  </p>
                  <p class="norm-static"><a name="jls-14.20.3.1-110"></a>The
                     meaning of a basic <code class="literal">try</code>-with-resources statement:
                  </p><a name="jls-14.20.3.1-120"></a><pre class="screen">
try (<span class="emphasis"><em>{VariableModifier} R Identifier</em></span> = <span class="emphasis"><em>Expression</em></span> ...)
    <span class="emphasis"><em>Block</em></span>
</pre><p class="norm-static"><a name="jls-14.20.3.1-130"></a>is
                     given by the following translation to a local variable declaration and
                     a <code class="literal">try</code>-<code class="literal">catch</code>-<code class="literal">finally</code> statement:
                  </p><a name="jls-14.20.3.1-140"></a><pre class="screen">
{
    final <span class="emphasis"><em>{VariableModifierNoFinal} R Identifier</em></span> = <span class="emphasis"><em>Expression</em></span>;
    Throwable #primaryExc = null;

    try <span class="emphasis"><em>ResourceSpecification_tail</em></span>
        <span class="emphasis"><em>Block</em></span>
    catch (Throwable #t) {
        #primaryExc = #t;
        throw #t;
    } finally {
        if (<span class="emphasis"><em>Identifier</em></span> != null) {
            if (#primaryExc != null) {
                try {
                    <span class="emphasis"><em>Identifier</em></span>.close();
                } catch (Throwable #suppressedExc) {
                    #primaryExc.addSuppressed(#suppressedExc);
                }
            } else {
                <span class="emphasis"><em>Identifier</em></span>.close();
            }
        }
    }
}
</pre><p class="norm-static"><a name="jls-14.20.3.1-200"></a>
                     <span class="emphasis"><em>{VariableModifierNoFinal}</em></span> is defined
                     as <span class="emphasis"><em>{VariableModifier}</em></span> without <code class="literal">final</code>, if
                     present.
                  </p>
                  <p class="norm-static"><a name="jls-14.20.3.1-210"></a>
                     <code class="literal">#t</code>, <code class="literal">#primaryExc</code>, and 
                     <code class="literal">#suppressedExc</code> are automatically generated
                     identifiers that are distinct from any other identifiers
                     (automatically generated or otherwise) that are in scope at the point
                     where the <code class="literal">try</code>-with-resources statement occurs.
                  </p>
                  <p class="norm-static"><a name="jls-14.20.3.1-220"></a>If the
                     resource specification declares one resource,
                     then <span class="emphasis"><em>ResourceSpecification_tail</em></span> is empty (and the
                     <code class="literal">try</code>-<code class="literal">catch</code>-<code class="literal">finally</code> statement is not itself a <code class="literal">try</code>-with-resources
                     statement).
                  </p>
                  <p class="norm-static"><a name="jls-14.20.3.1-230"></a>If the
                     resource specification declares <span class="emphasis"><em>n</em></span> &gt; 1 resources,
                     then <span class="emphasis"><em>ResourceSpecification_tail</em></span> consists of the
                     2nd, 3rd, ..., <span class="emphasis"><em>n</em></span>'th resources declared in resource specification,
                     in the same order (and the <code class="literal">try</code>-<code class="literal">catch</code>-<code class="literal">finally</code> statement is itself
                     a <code class="literal">try</code>-with-resources statement).
                  </p>
                  <p class="norm-static"><a name="jls-14.20.3.1-300"></a>
                     Reachability and definite assignment rules for the basic
                     <code class="literal">try</code>-with-resources statement are implicitly specified by the
                     translation above.
                  </p>
                  <p class="norm-dynamic"><a name="jls-14.20.3.1-400"></a>
                     In a basic <code class="literal">try</code>-with-resources statement that manages a single
                     resource:
                  </p>
                  <div class="norm">
                     <ul class="norm" type="disc">
                        <li class="listitem">
                           <p class="norm-dynamic"><a name="jls-14.20.3.1-400-A"></a>
                                    If the initialization of the resource completes abruptly because
                                    of a <code class="literal">throw</code> of a value <code class="varname">V</code>, then the
                                    <code class="literal">try</code>-with-resources statement completes abruptly because of a
                                    <code class="literal">throw</code> of the value <code class="varname">V</code>.
                           </p>
                        </li>
                        <li class="listitem">
                           <p class="norm-dynamic"><a name="jls-14.20.3.1-400-B"></a>
                                    If the initialization of the resource completes normally, and
                                    the <code class="literal">try</code> block completes abruptly because of a <code class="literal">throw</code> of a
                                    value <code class="varname">V</code>, then:
                           </p>
                           <div class="norm">
                              <ul class="norm" type="circle">
                                 <li class="listitem">
                                    <p class="norm-dynamic"><a name="jls-14.20.3.1-400-B-A"></a>
                                       	  If the automatic closing of the resource completes normally,
                                       	  then the <code class="literal">try</code>-with-resources statement completes abruptly
                                       	  because of a <code class="literal">throw</code> of the value <code class="varname">V</code>.
                                    </p>
                                 </li>
                                 <li class="listitem">
                                    <p class="norm-dynamic"><a name="jls-14.20.3.1-400-B-B"></a>
                                       	  If the automatic closing of the resource completes abruptly
                                       	  because of a <code class="literal">throw</code> of a value <code class="varname">V2</code>, then
                                       	  the <code class="literal">try</code>-with-resources statement completes abruptly
                                       	  because of a <code class="literal">throw</code> of value <code class="varname">V</code>
                                       	  with <code class="varname">V2</code> added to the suppressed exception
                                       	  list of <code class="varname">V</code>.
                                    </p>
                                 </li>
                              </ul>
                           </div>
                        </li>
                        <li class="listitem">
                           <p class="norm-dynamic"><a name="jls-14.20.3.1-400-C"></a>
                                    If the initialization of the resource completes normally, and
                                    the <code class="literal">try</code> block completes normally, and the automatic closing of
                                    the resource completes abruptly because of a <code class="literal">throw</code> of a
                                    value <code class="varname">V</code>, then the <code class="literal">try</code>-with-resources
                                    statement completes abruptly because of a <code class="literal">throw</code> of the
                                    value <code class="varname">V</code>.
                           </p>
                        </li>
                     </ul>
                  </div>
                  <p class="norm-dynamic"><a name="jls-14.20.3.1-500"></a>In a
                     basic <code class="literal">try</code>-with-resources statement that manages multiple
                     resources:
                  </p>
                  <div class="norm">
                     <ul class="norm" type="disc">
                        <li class="listitem">
                           <p class="norm-dynamic"><a name="jls-14.20.3.1-500-A"></a>
                                    If the initialization of a resource completes abruptly because
                                    of a <code class="literal">throw</code> of a value <code class="varname">V</code>, then:
                           </p>
                           <div class="norm">
                              <ul class="norm" type="circle">
                                 <li class="listitem">
                                    <p class="norm-dynamic"><a name="jls-14.20.3.1-500-A-A"></a>
                                       	  If the automatic closings of all successfully initialized
                                       	  resources (possibly zero) complete normally, then the
                                       	  <code class="literal">try</code>-with-resources statement completes abruptly because of
                                       	  a <code class="literal">throw</code> of the value <code class="varname">V</code>.
                                    </p>
                                 </li>
                                 <li class="listitem">
                                    <p class="norm-dynamic"><a name="jls-14.20.3.1-500-A-B"></a>
                                       	  If the automatic closings of all successfully initialized
                                       	  resources (possibly zero) complete abruptly because of
                                       	  <code class="literal">throw</code>s of
                                       	  values <code class="varname">V1</code>...<code class="varname">Vn</code>, then
                                       	  the <code class="literal">try</code>-with-resources statement completes abruptly
                                       	  because of a <code class="literal">throw</code> of the value <code class="varname">V</code> with
                                       	  any remaining
                                       	  values <code class="varname">V1</code>...<code class="varname">Vn</code> added
                                       	  to the suppressed exception list
                                       	  of <code class="varname">V</code>.
                                    </p>
                                 </li>
                              </ul>
                           </div>
                        </li>
                        <li class="listitem">
                           <p class="norm-dynamic"><a name="jls-14.20.3.1-500-B"></a>
                                    If the initialization of all resources completes normally, and
                                    the <code class="literal">try</code> block completes abruptly because of a <code class="literal">throw</code> of a
                                    value <code class="varname">V</code>, then:
                           </p>
                           <div class="norm">
                              <ul class="norm" type="circle">
                                 <li class="listitem">
                                    <p class="norm-dynamic"><a name="jls-14.20.3.1-500-B-A"></a>
                                       	  If the automatic closings of all initialized resources
                                       	  complete normally, then the <code class="literal">try</code>-with-resources statement
                                       	  completes abruptly because of a <code class="literal">throw</code> of the
                                       	  value <code class="varname">V</code>.
                                    </p>
                                 </li>
                                 <li class="listitem">
                                    <p class="norm-dynamic"><a name="jls-14.20.3.1-500-B-B"></a>
                                       	  If the automatic closings of one or more initialized
                                       	  resources complete abruptly because of <code class="literal">throw</code>s of
                                       	  values <code class="varname">V1</code>...<code class="varname">Vn</code>, then
                                       	  the <code class="literal">try</code>-with-resources statement completes abruptly
                                       	  because of a <code class="literal">throw</code> of the value <code class="varname">V</code> with
                                       	  any remaining
                                       	  values <code class="varname">V1</code>...<code class="varname">Vn</code> added
                                       	  to the suppressed exception list
                                       	  of <code class="varname">V</code>.
                                    </p>
                                 </li>
                              </ul>
                           </div>
                        </li>
                        <li class="listitem">
                           <p class="norm-dynamic"><a name="jls-14.20.3.1-500-C"></a>
                                    If the initialization of every resource completes normally, and
                                    the <code class="literal">try</code> block completes normally, then:
                           </p>
                           <div class="norm">
                              <ul class="norm" type="circle">
                                 <li class="listitem">
                                    <p class="norm-dynamic"><a name="jls-14.20.3.1-500-C-A"></a>
                                       	  If one automatic closing of an initialized resource
                                       	  completes abruptly because of a <code class="literal">throw</code> of
                                       	  value <code class="varname">V</code>, and all other automatic closings
                                       	  of initialized resources complete normally, then the
                                       	  <code class="literal">try</code>-with-resources statement completes abruptly because of
                                       	  a <code class="literal">throw</code> of the value <code class="varname">V</code>.
                                    </p>
                                 </li>
                                 <li class="listitem">
                                    <p class="norm-dynamic"><a name="jls-14.20.3.1-500-C-B"></a>
                                       	  If more than one automatic closing of an initialized
                                       	  resource completes abruptly because of <code class="literal">throw</code>s of
                                       	  values <code class="varname">V1</code>...<code class="varname">Vn</code>, then
                                       	  the <code class="literal">try</code>-with-resources statement completes abruptly
                                       	  because of a <code class="literal">throw</code> of the value <code class="varname">V1</code> with
                                       	  any remaining
                                       	  values <code class="varname">V2</code>...<code class="varname">Vn</code> added
                                       	  to the suppressed exception list of <code class="varname">V1</code>
                                       	  (where <code class="varname">V1</code> is the exception from the
                                       	  rightmost resource failing to close
                                       	  and <code class="varname">Vn</code> is the exception from the leftmost
                                       	  resource failing to close).
                                    </p>
                                 </li>
                              </ul>
                           </div>
                        </li>
                     </ul>
                  </div>
               </div>
               <div class="section" title="14.20.3.2.&nbsp;Extended try-with-resources">
                  <div class="titlepage">
                     <div>
                        <div>
                           <h4 class="title"><a name="jls-14.20.3.2"></a>14.20.3.2.&nbsp;Extended <code class="literal">try</code>-with-resources
                           </h4>
                        </div>
                     </div>
                  </div>
                  <p class="norm"><a name="jls-14.20.3.2-100"></a>A <code class="literal">try</code>-with-resources
                     statement with at least one <code class="literal">catch</code> clause and/or a <code class="literal">finally</code> clause
                     is called an <span class="emphasis"><em>extended</em></span> <code class="literal">try</code>-with-resources
                     statement.
                  </p>
                  <p class="norm-static"><a name="jls-14.20.3.2-110"></a>The
                     meaning of an extended <code class="literal">try</code>-with-resources statement:
                  </p><a name="jls-14.20.3.2-120"></a><pre class="screen">
try <span class="emphasis"><em>ResourceSpecification</em></span>
    <span class="emphasis"><em>Block</em></span>
<span class="emphasis"><em>[Catches]</em></span>
<span class="emphasis"><em>[Finally]</em></span>
</pre><p class="norm-static"><a name="jls-14.20.3.2-130"></a>is
                     given by the following translation to a basic <code class="literal">try</code>-with-resources
                     statement nested inside a <code class="literal">try</code>-<code class="literal">catch</code> or <code class="literal">try</code>-<code class="literal">finally</code> or
                     <code class="literal">try</code>-<code class="literal">catch</code>-<code class="literal">finally</code> statement:
                  </p><a name="jls-14.20.3.2-140"></a><pre class="screen">
try {
    try <span class="emphasis"><em>ResourceSpecification</em></span>
        Block
}
<span class="emphasis"><em>[Catches]</em></span>
<span class="emphasis"><em>[Finally]</em></span>
</pre><p class="norm-static"><a name="jls-14.20.3.2-200"></a>The
                     effect of the translation is to put the resource specification
                     "inside" the <code class="literal">try</code> statement. This allows a <code class="literal">catch</code> clause of an
                     extended <code class="literal">try</code>-with-resources statement to catch an exception due to
                     the automatic initialization or closing of any resource.
                  </p>
                  <p class="norm-static"><a name="jls-14.20.3.2-210"></a>
                     Furthermore, all resources will have been closed (or attempted to be
                     closed) by the time the <code class="literal">finally</code> block is executed, in keeping with
                     the intent of the <code class="literal">finally</code> keyword.
                  </p>
               </div>
            </div>
         </div>
         <div class="section" title="14.21.&nbsp;Unreachable Statements">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-14.21"></a>14.21.&nbsp;Unreachable Statements
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm-error"><a name="jls-14.21-100"></a>It is a
               compile-time error if a statement cannot be executed because it is
               <span class="emphasis"><em>unreachable</em></span>.  
            </p>
            <p class="note">This section is devoted to a precise explanation of
               the word "reachable." The idea is that there must be some possible
               execution path from the beginning of the constructor, method, instance
               initializer, or static initializer that contains the statement to the
               statement itself. The analysis takes into account the structure of
               statements. Except for the special treatment of <code class="literal">while</code>, <code class="literal">do</code>, and
               <code class="literal">for</code> statements whose condition expression has the constant value
               <code class="literal">true</code>, the values of expressions are not taken into account in the
               flow analysis.
            </p>
            <div class="informalexample">
               <p class="note">For example, a Java compiler will accept the
                  code:
               </p><pre class="screen">
{
    int n = 5;
    while (n &gt; 7) k = 2;
}
</pre><p class="note">even though the value of <code class="literal">n</code> is
                  known at compile time and in principle it can be known at compile time
                  that the assignment to <code class="literal">k</code> can never be
                  executed.
               </p>
            </div>
            <p class="norm"><a name="jls-14.21-200"></a>The rules in this section
               define two technical terms:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-200-A"></a>whether a statement
                            is <span class="emphasis"><em>reachable</em></span></p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-200-B"></a>whether a
                            statement <span class="emphasis"><em>can complete normally</em></span></p>
                  </li>
               </ul>
            </div>
            <p class="norm"><a name="jls-14.21-210"></a>The definitions here allow a
               statement to complete normally only if it is reachable.
            </p>
            <p class="norm"><a name="jls-14.21-220"></a>To shorten the description of
               the rules, the customary abbreviation "iff" is used to mean "if and
               only if."
            </p>
            <p class="norm-static"><a name="jls-14.21-230"></a>A reachable <code class="literal">break</code>
               statement <span class="emphasis"><em>exits a statement</em></span> if, within the break
               target, either there are no <code class="literal">try</code> statements whose <code class="literal">try</code> blocks
               contain the <code class="literal">break</code> statement, or there are <code class="literal">try</code> statements whose
               <code class="literal">try</code> blocks contain the <code class="literal">break</code> statement and all <code class="literal">finally</code> clauses
               of those <code class="literal">try</code> statements can complete normally.
            </p>
            <p class="note">This definition is based on the logic around
               "attempts to transfer control" in <a class="xref" href="jls-14.html#jls-14.15" title="14.15.&nbsp;The break Statement">&sect;14.15</a>.
            </p>
            <p class="norm-static"><a name="jls-14.21-240"></a>A <code class="literal">continue</code>
               statement <span class="emphasis"><em>continues a <code class="literal">do</code> statement</em></span> if, within
               the <code class="literal">do</code> statement, either there are no <code class="literal">try</code> statements whose <code class="literal">try</code>
               blocks contain the <code class="literal">continue</code> statement, or there are <code class="literal">try</code> statements
               whose <code class="literal">try</code> blocks contain the <code class="literal">continue</code> statement and all <code class="literal">finally</code>
               clauses of those <code class="literal">try</code> statements can complete normally.
            </p>
            <p class="norm"><a name="jls-14.21-300"></a>The rules are as
               follows:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-300-A"></a>The block that is the
                            body of a constructor, method, instance initializer, or static
                            initializer is reachable.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-300-B"></a>An empty block that is
                            not a switch block can complete normally iff it is
                            reachable.
                     </p>
                     <p class="norm"><a name="jls-14.21-300-B.1"></a>A non-empty block
                            that is not a switch block can complete normally iff the last
                            statement in it can complete normally.
                     </p>
                     <p class="norm"><a name="jls-14.21-300-B.2"></a>The first statement
                            in a non-empty block that is not a switch block is reachable iff
                            the block is reachable.
                     </p>
                     <p class="norm"><a name="jls-14.21-300-B.3"></a>Every other
                            statement <code class="varname">S</code> in a non-empty block that is not a
                            switch block is reachable iff the statement
                            preceding <code class="varname">S</code> can complete normally.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-300-C"></a>A local class
                            declaration statement can complete normally iff it is
                            reachable.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-300-D"></a>A local variable
                            declaration statement can complete normally iff it is
                            reachable.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-300-E"></a>An empty statement can
                            complete normally iff it is reachable.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-300-F"></a>A labeled statement can
                            complete normally if at least one of the following is true:
                     </p>
                     <div class="norm">
                        <ul class="norm" type="circle">
                           <li class="listitem">
                              <p class="norm"><a name="jls-14.21-300-F-1"></a>The contained
                                 	statement can complete normally.
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="norm"><a name="jls-14.21-300-F-2"></a>There is a
                                 	reachable <code class="literal">break</code> statement that exits the labeled
                                 	statement.
                              </p>
                           </li>
                        </ul>
                     </div>
                     <p class="norm"><a name="jls-14.21-300-F.1"></a>The contained
                            statement is reachable iff the labeled statement is
                            reachable.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-300-G"></a>An expression statement
                            can complete normally iff it is reachable.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-300-H-1"></a>An <code class="literal">if</code>-<code class="literal">then</code>
                             statement can complete normally iff it is reachable.
                     </p>
                     <p class="norm"><a name="jls-14.21-300-H-2"></a>The <code class="literal">then</code>-statement
                             is reachable iff the <code class="literal">if</code>-<code class="literal">then</code> statement is
                             reachable.
                     </p>
                     <p class="norm"><a name="jls-14.21-300-H-3"></a>An <code class="literal">if</code>-<code class="literal">then</code>-<code class="literal">else</code>
                             statement can complete normally iff
                             the <code class="literal">then</code>-statement can complete normally or the
                             <code class="literal">else</code>-statement can complete normally.
                     </p>
                     <p class="norm"><a name="jls-14.21-300-H-4"></a>The <code class="literal">then</code>-statement
                             is reachable iff the <code class="literal">if</code>-<code class="literal">then</code>-<code class="literal">else</code> statement is
                             reachable.
                     </p>
                     <p class="norm"><a name="jls-14.21-300-H-5"></a>The <code class="literal">else</code>-statement
                             is reachable iff the <code class="literal">if</code>-<code class="literal">then</code>-<code class="literal">else</code> statement is
                             reachable.
                     </p>
                     <p class="note">This handling of an <code class="literal">if</code> statement, whether or
                             not it has an <code class="literal">else</code> part, is rather unusual. The rationale is
                             given at the end of this section.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-300-I"></a>An <code class="literal">assert</code> statement
                            can complete normally iff it is reachable.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-300-J"></a>A <code class="literal">switch</code> statement
                            can complete normally iff at least one of the following is
                            true:
                     </p>
                     <div class="norm">
                        <ul class="norm" type="circle">
                           <li class="listitem">
                              <p class="norm"><a name="jls-14.21-300-J-1"></a>The switch block
                                 	 is empty or contains only switch labels.
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="norm"><a name="jls-14.21-300-J-2"></a>The last
                                 	 statement in the switch block can complete normally.
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="norm"><a name="jls-14.21-300-J-3"></a>There is at least
                                 	 one switch label after the last switch block statement
                                 	 group.
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="norm"><a name="jls-14.21-300-J-4"></a>The switch block
                                 	 does not contain a <code class="literal">default</code> label.
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="norm"><a name="jls-14.21-300-J-5"></a>There is a
                                 	 reachable <code class="literal">break</code> statement that exits the <code class="literal">switch</code>
                                 	 statement.
                              </p>
                           </li>
                        </ul>
                     </div>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-300-K"></a>A switch block is
                            reachable iff its <code class="literal">switch</code> statement is reachable.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-300-L"></a>A statement in a switch
                            block is reachable iff its <code class="literal">switch</code> statement is reachable and at
                            least one of the following is true:
                     </p>
                     <div class="norm">
                        <ul class="norm" type="circle">
                           <li class="listitem">
                              <p class="norm"><a name="jls-14.21-300-L-1"></a>It bears a <code class="literal">case</code>
                                 	or <code class="literal">default</code> label.
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="norm"><a name="jls-14.21-300-L-2"></a>There is a statement preceding it in the
                                 	switch block and that preceding statement can complete
                                 	normally.
                              </p>
                           </li>
                        </ul>
                     </div>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-300-M"></a>A <code class="literal">while</code> statement can
                             complete normally iff at least one of the following is
                             true:
                     </p>
                     <div class="norm">
                        <ul class="norm" type="circle">
                           <li class="listitem">
                              <p class="norm"><a name="jls-14.21-300-M-1"></a>The <code class="literal">while</code>
                                 	statement is reachable and the condition expression is not a
                                 	constant expression (<a class="xref" href="jls-15.html#jls-15.28" title="15.28.&nbsp;Constant Expressions">&sect;15.28</a>) with value
                                 	<code class="literal">true</code>.
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="norm"><a name="jls-14.21-300-M-2"></a>There is a
                                 	reachable <code class="literal">break</code> statement that exits the <code class="literal">while</code>
                                 	statement.
                              </p>
                           </li>
                        </ul>
                     </div>
                     <p class="norm"><a name="jls-14.21-300-M.1"></a>The contained
                             statement is reachable iff the <code class="literal">while</code> statement is reachable and
                             the condition expression is not a constant expression whose value
                             is <code class="literal">false</code>.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-300-N"></a>A <code class="literal">do</code> statement can
                            complete normally iff at least one of the following is
                            true:
                     </p>
                     <div class="norm">
                        <ul class="norm" type="circle">
                           <li class="listitem">
                              <p class="norm"><a name="jls-14.21-300-N-1"></a>The contained
                                 	statement can complete normally and the condition expression
                                 	is not a constant expression (<a class="xref" href="jls-15.html#jls-15.28" title="15.28.&nbsp;Constant Expressions">&sect;15.28</a>)
                                 	with value <code class="literal">true</code>.
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="norm"><a name="jls-14.21-300-N-2"></a>The
                                 	<code class="literal">do</code> statement contains a reachable <code class="literal">continue</code> statement with
                                 	no label, and the <code class="literal">do</code> statement is the innermost <code class="literal">while</code>,
                                 	<code class="literal">do</code>, or <code class="literal">for</code> statement that contains that <code class="literal">continue</code>
                                 	statement, and the <code class="literal">continue</code> statement continues
                                 	that <code class="literal">do</code> statement, and the condition expression is
                                 	not a constant expression with value <code class="literal">true</code>.
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="norm"><a name="jls-14.21-300-N-3"></a>The
                                 	<code class="literal">do</code> statement contains a reachable <code class="literal">continue</code> statement with
                                 	a label <code class="varname">L</code>, and the <code class="literal">do</code> statement has
                                 	label <code class="varname">L</code>, and the <code class="literal">continue</code>
                                 	statement continues that <code class="literal">do</code> statement, and the
                                 	condition expression is not a constant expression with value
                                 	<code class="literal">true</code>.
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="norm"><a name="jls-14.21-300-N-4"></a>There is a
                                 	reachable <code class="literal">break</code> statement that exits the <code class="literal">do</code>
                                 	statement.
                              </p>
                           </li>
                        </ul>
                     </div>
                     <p class="norm"><a name="jls-14.21-300-N.1"></a>The contained
                             statement is reachable iff the <code class="literal">do</code> statement is
                             reachable.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-300-O"></a>A basic <code class="literal">for</code> statement
                             can complete normally iff at least one of the following is
                             true:
                     </p>
                     <div class="norm">
                        <ul class="norm" type="circle">
                           <li class="listitem">
                              <p class="norm"><a name="jls-14.21-300-O-1"></a>The <code class="literal">for</code>
                                 	statement is reachable, there is a condition expression, and
                                 	the condition expression is not a constant expression
                                 	(<a class="xref" href="jls-15.html#jls-15.28" title="15.28.&nbsp;Constant Expressions">&sect;15.28</a>) with value <code class="literal">true</code>.
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="norm"><a name="jls-14.21-300-O-2"></a>There is a
                                 	reachable <code class="literal">break</code> statement that exits the <code class="literal">for</code>
                                 	statement.
                              </p>
                           </li>
                        </ul>
                     </div>
                     <p class="norm"><a name="jls-14.21-300-O.1"></a>The contained
                            statement is reachable iff the <code class="literal">for</code> statement is reachable and
                            the condition expression is not a constant expression whose value
                            is <code class="literal">false</code>.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-300-P"></a>An enhanced <code class="literal">for</code>
                            statement can complete normally iff it is reachable.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-300-Q"></a>A <code class="literal">break</code>, <code class="literal">continue</code>,
                            <code class="literal">return</code>, or <code class="literal">throw</code> statement cannot complete normally.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-300-R"></a>A <code class="literal">synchronized</code>
                            statement can complete normally iff the contained statement can
                            complete normally.
                     </p>
                     <p class="norm"><a name="jls-14.21-300-R.1"></a>The contained
                            statement is reachable iff the <code class="literal">synchronized</code> statement is
                            reachable.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-300-S"></a>A <code class="literal">try</code> statement can
                            complete normally iff both of the following are true:
                     </p>
                     <div class="norm">
                        <ul class="norm" type="circle">
                           <li class="listitem">
                              <p class="norm"><a name="jls-14.21-300-S-1"></a>The <code class="literal">try</code> block
                                 	can complete normally or any <code class="literal">catch</code> block can complete
                                 	normally.
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="norm"><a name="jls-14.21-300-S-2"></a>If the <code class="literal">try</code>
                                 	statement has a <code class="literal">finally</code> block, then the <code class="literal">finally</code> block can
                                 	complete normally.
                              </p>
                           </li>
                        </ul>
                     </div>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-300-T"></a>The <code class="literal">try</code> block is
                            reachable iff the <code class="literal">try</code> statement is reachable.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-300-U"></a>A <code class="literal">catch</code>
                            block <code class="varname">C</code> is reachable iff both of the following
                            are true:
                     </p>
                     <div class="norm">
                        <ul class="norm" type="circle">
                           <li class="listitem">
                              <p class="norm"><a name="jls-14.21-300-U-1"></a>Either the type
                                 	of <code class="varname">C</code>'s parameter is an unchecked exception
                                 	type or <code class="literal">Exception</code> or a superclass of <code class="literal">Exception</code>, or some expression or <code class="literal">throw</code> statement in the <code class="literal">try</code> block
                                 	is reachable and can throw a  checked 
                                 	exception whose type is assignable to the type
                                 	of <code class="varname">C</code>'s parameter. (An expression is
                                 	reachable iff the innermost statement containing it is
                                 	reachable.)
                              </p>
                              <p class="note">See <a class="xref" href="jls-15.html#jls-15.6" title="15.6.&nbsp;Normal and Abrupt Completion of Evaluation">&sect;15.6</a> for normal
                                 	and abrupt completion of expressions.
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="norm"><a name="jls-14.21-300-U-2"></a>There is no
                                 	earlier <code class="literal">catch</code> block <code class="varname">A</code> in the <code class="literal">try</code>
                                 	statement such that the type of <code class="varname">C</code>'s
                                 	parameter is the same as or a subclass of the type
                                 	of <code class="varname">A</code>'s parameter.
                              </p>
                           </li>
                        </ul>
                     </div>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-300-V"></a>The <span class="emphasis"><em>Block</em></span> of a <code class="literal">catch</code> block is reachable
                            iff the <code class="literal">catch</code> block is reachable.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-14.21-300-W"></a>If a <code class="literal">finally</code> block is
                            present, it is reachable iff the <code class="literal">try</code> statement is
                            reachable.
                     </p>
                  </li>
               </ul>
            </div>
            <p class="note">One <span class="emphasis"><em>might expect</em></span> the <code class="literal">if</code>
               statement to be handled in the following manner:
            </p>
            <div class="note">
               <ul class="note" type="disc">
                  <li class="listitem">
                     <p class="note">An <code class="literal">if</code>-<code class="literal">then</code> statement can
                            complete normally iff at least one of the following is
                            true:
                     </p>
                     <div class="note">
                        <ul class="note" type="circle">
                           <li class="listitem">
                              <p class="note">The <code class="literal">if</code>-<code class="literal">then</code> statement is reachable and
                                 	the condition expression is not a constant expression whose
                                 	value is <code class="literal">true</code>.
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="note">The <code class="literal">then</code>-statement can complete
                                 	normally.
                              </p>
                           </li>
                        </ul>
                     </div>
                     <p class="note">The <code class="literal">then</code>-statement is reachable iff the
                            <code class="literal">if</code>-<code class="literal">then</code> statement is reachable and the condition expression is
                            not a constant expression whose value is <code class="literal">false</code>.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="note">An <code class="literal">if</code>-<code class="literal">then</code>-<code class="literal">else</code> statement can complete
                            normally iff the <code class="literal">then</code>-statement can complete normally or the
                            <code class="literal">else</code>-statement can complete normally.
                     </p>
                     <p class="note">The <code class="literal">then</code>-statement is reachable iff the
                            <code class="literal">if</code>-<code class="literal">then</code>-<code class="literal">else</code> statement is reachable and the condition
                            expression is not a constant expression whose value is
                            <code class="literal">false</code>.
                     </p>
                     <p class="note">The <code class="literal">else</code>-statement is reachable iff the
                            <code class="literal">if</code>-<code class="literal">then</code>-<code class="literal">else</code> statement is reachable and the condition
                            expression is not a constant expression whose value is
                            <code class="literal">true</code>.
                     </p>
                  </li>
               </ul>
            </div>
            <p class="note">This approach would be consistent with the treatment
               of other control structures. However, in order to allow the if
               statement to be used conveniently for "conditional compilation"
               purposes, the actual rules differ.
            </p>
            <p class="note">As an example, the following statement results in a
               compile-time error:
            </p><pre class="screen">
while (false) { x=3; }
</pre><p class="note">because the statement <code class="literal">x=3;</code> is not
               reachable; but the superficially similar case:
            </p><pre class="screen">
if (false) { x=3; }
</pre><p class="note">does not result in a compile-time error. An
               optimizing compiler may realize that the
               statement <code class="literal">x=3;</code> will never be executed and may
               choose to omit the code for that statement from the
               generated <code class="literal">class</code> file, but the
               statement <code class="literal">x=3;</code> is not regarded as "unreachable" in
               the technical sense specified here.
            </p>
            <p class="note">The rationale for this differing treatment is to
               allow programmers to define "flag variables" such as:
            </p><pre class="screen">
static final boolean DEBUG = false;
</pre><p class="note">and then write code such as:</p><pre class="screen">
if (DEBUG) { x=3; }
</pre><p class="note">The idea is that it should be possible to change the
               value of <code class="literal">DEBUG</code> from <code class="literal">false</code> to <code class="literal">true</code> or from
               <code class="literal">true</code> to <code class="literal">false</code> and then compile the code correctly with no other
               changes to the program text.
            </p>
            <p class="note">
               This ability to "conditionally compile" has no relationship to binary
               compatibility (<a class="xref" href="jls-13.html" title="Chapter&nbsp;13.&nbsp;Binary Compatibility">&sect;13 (<i>Binary Compatibility</i>)</a>). If a set of classes that use
               such a "flag" variable are compiled and conditional code is omitted,
               it does not suffice later to distribute just a new version of the
               class or interface that contains the definition of the flag. The
               classes that use the flag will not see its new value, so their
               behavior may be surprising, but no <code class="literal">LinkageError</code> will occur. A change to the
               value of a flag is, therefore, binary compatible with pre-existing
               binaries, but not behaviorally compatible.
            </p>
         </div>
      </div>
      <div class="navfooter">
         <hr>
         <table width="100%" summary="Navigation footer">
            <tr>
               <td width="40%" align="left"><a accesskey="p" href="jls-13.html">Prev</a>&nbsp;
               </td>
               <td width="20%" align="center">&nbsp;</td>
               <td width="40%" align="right">&nbsp;<a accesskey="n" href="jls-15.html">Next</a></td>
            </tr>
            <tr>
               <td width="40%" align="left" valign="top">Chapter&nbsp;13.&nbsp;Binary Compatibility&nbsp;</td>
               <td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
               <td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;15.&nbsp;Expressions</td>
            </tr>
         </table>
      </div>
      <div xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:rx="http://www.renderx.com/XSL/Extensions" class="navfooter">
         <hr><a href="jls-0-front.html">
                Legal Notice
              </a></div>
   </body>
</html>